iOS Unicode和漢字互轉




//unicode轉中文 NSString* strA = [@"%E4%B8%AD%E5%9B%BD"stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //中文轉unicode NSString *strB = [@"中國"stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

ios9以後ios

NSString *urlStr = @"url地址";ui

//中文轉unicode urlStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; //unicode轉中文 urlStr = [urlStr stringByRemovingPercentEncoding];

知道他們兩個的區別嗎?stringByReplacingPercentEscapesUsingEncoding  和stringByAddingPercentEscapesUsingEncoding。待續。。。。。
 unicode
相關文章
相關標籤/搜索