ios UTF8编码从nsstring [英] ios UTF8 encoding from nsstring

查看:195
本文介绍了ios UTF8编码从nsstring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个不正确编码的nsstring,如mystring%201,其中必须是mystring 1。如何替换所有可以解释为UTF8的字符?我读了很多帖子,但不是一个完整的解决方案请注意nsstring已经编码错误,我不是在询问如何编码字符序列。

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.

推荐答案

- (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding 是你想要的基本上使用它像这样:

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

newString = [myString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

这篇关于ios UTF8编码从nsstring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆