Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 UTF8? I read a lot of posts but not a full solution. Please note that nsstring is already encoded wrong and I am not asking about how to encode char sequence. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
403 views
Welcome To Ask or Share your Answers For Others

1 Answer

- (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding is what you want. basically use it like so:

newString = [myString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...