How to decode a string with gb2312encode to chinese in objective-c? -


i have string @"%a9e%b7%cb%ce%d2%a9b%cb%bc%b4%e6",decode online is@"〆匪我゜思存", how use oc decode string chinese ?

you can try below code.

-(nsstring *)encodegb2312str:(nsstring *)encodestr {     cfstringref nonalphanumvalidchars = cfstr("![        discuz_code_1        ]’()*+,-./:;=?@_~");     nsstring *preprocessedstring = (nsstring *)cfbridgingrelease(cfurlcreatestringbyreplacingpercentescapesusingencoding(kcfallocatordefault, (cfstringref)encodestr, cfstr(""), kcfstringencodinggb_18030_2000));     nsstring *newstr = (nsstring *)cfbridgingrelease(cfurlcreatestringbyaddingpercentescapes(kcfallocatordefault,(cfstringref)preprocessedstring,null,nonalphanumvalidchars,kcfstringencodinggb_18030_2000));     return newstr;  }  nsstring *string = [self encodegb2312str:@"〆匪我゜思存"];  nslog(@"string = %@",string); //output string = %a9%65%b7%cb%ce%d2%20%cb%bc%b4%e6 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -