/**decode encoded */- (nsstring *) encodetopercentescapestring{ nsstring* outputStr = (__bridge nsstring *) cfurlcreatestringbyaddingpercentescapes ( NULL, /* allocator */ (__bridge  CFSTRINGREF) self, null, /* characterstoleaveunescaped */ (Cfstringref) @ "!*" ();: @&=+$,/?%#[] ", kcfsTRINGENCODINGUTF8); return outputstr;} /**decode decoding */- (nsstring *) decodefrompercentescapestring{ nsmutablestring *outputstr = [nsmutablestring stringwithstring:self]; [outputstr replaceoccurrencesofstring:@ "+" withstring:@ "" options:NSLiteralSearch & NBsP; range:nsmakerange (0,[outputstr length])]; return [outputstr stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];}
This article is from the "snowflakes flying over the World" blog, please be sure to keep this source http://smengxiang.blog.51cto.com/11204872/1871973
IOS encode decoding and encoding