0

我正在尝试解析以下阿拉伯语内容

<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 应用程序上显示内容的方式

请让我知道我该如何解决这个问题

4

2 回答 2

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
};
于 2012-08-03T11:58:21.050 回答
0

首先,在检查您的响应字符串(<?xml version="1.0" encoding="Change here" ?><type>)之后,它看起来是 xml 编码类型的问题。告诉您的 Web 开发人员为阿拉伯语内容提供正确的编码,并检查它在浏览器中的响应是否正确显示,然后在您身边尝试各种编码。它肯定会修复。

于 2012-08-06T04:03:57.187 回答