NSString *urlStr = @"www.baidu.com/百度";
iOS9之前
urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
iOS9之后
urlStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
打印结果
www.baidu.com/%E7%99%BE%E5%BA%A6
www.baidu.com/%E7%99%BE%E5%BA%A6