本文介绍了如何在iphone中解码UTF8字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想解码UT8编码的字符串。
I want to decode an UT8 encoded string.
输入字符串是øÃ|-test-2.txt
,解码后应成为
øæ-test-2.txt
我发现许多API将NSString或NSData编码为UT8(NSUTF8StringEncoding),但无法找到解码方式。
I found many API to encode the NSString or NSData to UT8 (NSUTF8StringEncoding) but was not able to find the way to decode it.
已经尝试过: -
NSString *str = [[NSString alloc] initWithUTF8String:[strToDecode cStringUsingEncoding:NSUTF8StringEncoding]];
AND
[strToDecode stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
AND
[NSString stringWithUTF8String:[strToDecode cStringUsingEncoding:[NSString defaultCStringEncoding]]]
我尝试过相同的输入字符串,并在。
I have tried the same input string and I get the proper output in third party decoder.
但无法获得成功
任何提示正确的提示将非常感谢。 >
Any hint in right direction would be highly appreciated.
推荐答案
[NSString stringWithUTF8String:]
这篇关于如何在iphone中解码UTF8字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!