我正在尝试解析以下阿拉伯语内容
<type id="14">
<data name="title">قافية</data>
</type>
NSString *responseString = [request responseString];
NSData *xmlData=[[request responseString] dataUsingEncoding:NSUTF8StringEncoding];
打印时我得到的回复
responseString:<?xml version="1.0" encoding="UTF-8" ?><type>
<data name="title">ÙاÙÙØ©</data>
</type>
请参阅附加的图片,这是我在ios应用中显示内容的方式
请让我知道如何解决此问题
答案 0 :(得分:1)
尝试使用以下编码,
// The following constants are provided by NSString as possible string encodings.
enum {
NSASCIIStringEncoding = 1,
NSNEXTSTEPStringEncoding = 2,
NSJapaneseEUCStringEncoding = 3,
NSUTF8StringEncoding = 4,
NSISOLatin1StringEncoding = 5,
NSSymbolStringEncoding = 6,
NSNonLossyASCIIStringEncoding = 7,
NSShiftJISStringEncoding = 8,
NSISOLatin2StringEncoding = 9,
NSUnicodeStringEncoding = 10,
NSWindowsCP1251StringEncoding = 11,
NSWindowsCP1252StringEncoding = 12,
NSWindowsCP1253StringEncoding = 13,
NSWindowsCP1254StringEncoding = 14,
NSWindowsCP1250StringEncoding = 15,
NSISO2022JPStringEncoding = 21,
NSMacOSRomanStringEncoding = 30,
NSUTF16StringEncoding = NSUnicodeStringEncoding,
NSUTF16BigEndianStringEncoding = 0x90000100,
NSUTF16LittleEndianStringEncoding = 0x94000100,
NSUTF32StringEncoding = 0x8c000100,
NSUTF32BigEndianStringEncoding = 0x98000100,
NSUTF32LittleEndianStringEncoding = 0x9c000100,
NSProprietaryStringEncoding = 65536
};
答案 1 :(得分:0)
首先检查你的响应字符串(<?xml version="1.0" encoding="Change here" ?><type>
)后,它看起来是xml编码类型的问题。告诉您的Web开发人员为阿拉伯语内容提供正确的编码,如果在您尝试各种编码后正确显示,请在浏览器中检查它的响应。它肯定会修复。