iOS9之前
字符串->UTF8
NSString *string = [string stringByAddingPercentEscapesUsingEncoding:
NSUTF8StringEncoding];
UTF8->字符串
NSString *string = [string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
iOS9之后
字符串->UTF8
NSString *string = [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
UTF8->字符串
NSString *string = [string stringByRemovingPercentEncoding];
网友评论