ios UTF8 encoding from nsstring

后端 未结 5 1575
小鲜肉
小鲜肉 2020-12-09 19:39

I am receiving a nsstring that is not properly encoded like \"mystring%201, where must be \"mystring 1\". How could I replace all characters that could be interpreted as UTF

5条回答
  •  失恋的感觉
    2020-12-09 20:34

    Do you want just percent encoding/decoding or full URL encoding/decoding? -(NSString*)stringByReplacingPercentEscapesUsingEncoding: will work if it is just percent encoding, but if there is full URL encoding there (so, for example a space could be either %20 or +) then you'll need something like the url decoding in the three20 library (or search on there, there are lots of examples of how to do it such as URL decoding/encoding NSString).

提交回复
热议问题