UTF-8 ->GBK

/**

 * GBK->UTF8

 */

//方法一 旧方法

//NSString *encode1 = [@"%E6%88%91" stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

//NSLog(@"--encode1->%@<------", encode1);

 

//方法二   新方法

//NSLog(@"--encode2->%@<------", [@"%E6%88%91" stringByRemovingPercentEncoding]);

 

/**

 *  UTF-8 ->GBK

 */

//方法一 旧方法

//NSString *decode1 = [@"我" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

//NSLog(@"--decode1-->%@<-----", decode1);

 

//方法二 新方法

//NSLog(@"--decode1-->%@<-----",  [@"我" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]);

posted @ 2016-06-14 14:04  乐多呀  阅读(439)  评论(0编辑  收藏  举报