如何encode:
let urlStrEncode = urlStr.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
或者
let urlStrEncode = urlStr.stringByAddingPercentEncodingWithAllowedCharacters( NSCharacterSet.URLQueryAllowedCharacterSet())
顺道再贴下如何decode:
let urlStrDecode = urlStrEncoded.stringByRemovingPercentEncoding