首页 > 代码库 > 汉字与utf8相互转化

汉字与utf8相互转化

-(void)NSUTF8StringEncodingAction{

    //汉字与utf8相互转化

    NSString *strA = [@"%E4%B8%AD%E5%9B%BD" stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSLog(@"汉字:%@",strA);

    NSString *utf8CityNameStr = [@"iOS工程师" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSLog(@"UTF8String:%@",utf8CityNameStr);

}

汉字与utf8相互转化