letsearchword:String="柴油0#"
/// encodeURIComponent编码方式,会对特殊符号编码
///方法一
//let toSearchword = searchword.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
///方法二
//let toSearchword = CFURLCreateStringByAddingPercentEscapes(nil, searchword, "!*'();:@&=+$,/?%#[]", nil, CFStringBuiltInEncodings.UTF8.rawValue)
/// encodeURI编码,不会对特殊符号编码
lettoSearchword =CFURLCreateStringByAddingPercentEscapes(nil, searchword,nil,"!*'();:@&=+$,/?%#[]",CFStringBuiltInEncodings.UTF8.rawValue)
print(toSearchword)
具体测试网址:http://www.bejson.com/enc/urlencode/