在iOS中将string转成UTF8编码

在iOS开发中,特别是在对Web服务调用的时候,经常会遇到请求参数为中文的情况,那么这时候就需要将Url转成UTF-8编码才能进行请求。
使用stringByAddingPercentEscapesUsingEncoding:方法可以将string转成UTF-8编码,
如下面代码

NSURL *url = [NSURL URLWithString: [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
原文地址:https://www.cnblogs.com/hellocby/p/2815891.html