问题描述
我有一些问题,在我的iPhone应用程序中显示一些阿拉伯文字。当我上显示它的UILabel
,它显示了像 ?????? ????? ??????
的字符串来自服务器的XML,我分析它,并显示一个UILabel。我不知道这是由于在iPhone或从服务器侧的一个问题。
-
我想知道我怎么能确定来自服务器的未来是有正确的编码,是一个有效的阿拉伯字符字符串。
-
是否足以打印值的每个字符,并检查它位于阿拉伯统一code字符之间。 (像字符A的ASCII值是65,而的Z值为90。因此,一个价值70必须是ASCII字符)。
-
在服务器字符串为EN $ C $光盘UTF8编码。而服务器程序用C#。什么是写编码方法阿拉伯文文本从服务器传送到iPhone?
-
我是否需要使用其他字体以正确显示阿拉伯字符。
-
有没有在上网阿拉伯语的内容,从那里我可以分析并正确显示阿拉伯语文本的任何XML文件?
在此先感谢。
编辑:
当我NSLogged XML数据我得到了相同的 ???? ???? ???
字符。
修改
请参阅我在控制台有一个XML风格的数据。
< CB_SEC_COMP>
< SC_COMP_ID> 9999< / SC_COMP_ID>
< SCA_LONG_NAME> ???? ????? ?????????? ????? ?????????< / SCA_LONG_NAME>
< SCE_LONG_NAME>中国安防和放大器;放大器;监控技术股份有限公司< / SCE_LONG_NAME>
< SCA_SHORT_NAME> ???? ????? ?????????< / SCA_SHORT_NAME>
< SCE_SHORT_NAME>中国安防和放大器;放大器; SUR< / SCE_SHORT_NAME>
< SC_MRK_ code> 9< / SC_MRK_ code取代;
< SC_SEC_ code> 86< / SC_SEC_ code取代;
< SC_STATUS> Y< / SC_STATUS>
< TICKER_ID>企业社会责任< / TICKER_ID>
< SC_MRK_TYPE_ code> 0001< / SC_MRK_TYPE_ code取代;
< SC_EXCHANGE> DFM< / SC_EXCHANGE>
< CUR_ code取代; AED< / CUR_ code取代;
< / CB_SEC_COMP>
感谢所有的答案。这个问题是不是与iPhone的一面。在服务器的XML并没有正确连接coded到UTF8字符串。当它正确连接codeD我得到了有效的阿拉伯字符。我只是做了code像
的NSString * lableText = [[NSString的页头] initWithData:serverSentData编码:NSUTF8StringEncoding]。
有关转换的NSData到NSString的,效果不错!
I have some problems with displaying some Arabic text in my iPhone application. When I am displaying it on a UILabel
, it shows like ?????? ????? ??????
The string comes from server as XML, I parse it and display on a UILabel. I dont know this is due to a problem in iPhone or from Server side.
I want to know how can I determine the string coming from server is having correct encoding and is a valid Arabic characters.
Is it suffice to print value each character and check it lies between Arabic Unicode characters. (Like ASCII value of character A is 65 and that of Z is 90. So a value 70 must be a ASCII character).
In server the string is encoded with UTF8 encoding. And server program written in c#. What is the write encoding method to transfer Arabic text from server to iPhone?
Do I need to use other fonts to display Arabic characters correctly.
Is there any XML file with Arabic content in Internet, from where I can parse and display arabic text correctly?
Thanks in advance..
EDIT:
When I NSLogged XML data I got same ???? ???? ???
characters.
EDIT
See a XML styled data that I got in console.
<CB_SEC_COMP>
<SC_COMP_ID>9999</SC_COMP_ID>
<SCA_LONG_NAME>???? ????? ?????????? ????? ?????????</SCA_LONG_NAME>
<SCE_LONG_NAME>CHINA SECURITY & SURVEILLANCE TECHNOLOGY, INC.</SCE_LONG_NAME>
<SCA_SHORT_NAME>???? ????? ?????????</SCA_SHORT_NAME>
<SCE_SHORT_NAME>CHINA SECURITY & SUR</SCE_SHORT_NAME>
<SC_MRK_CODE>9</SC_MRK_CODE>
<SC_SEC_CODE>86</SC_SEC_CODE>
<SC_STATUS>Y</SC_STATUS>
<TICKER_ID>CSR</TICKER_ID>
<SC_MRK_TYPE_CODE>0001</SC_MRK_TYPE_CODE>
<SC_EXCHANGE>DFM</SC_EXCHANGE>
<CUR_CODE>AED</CUR_CODE>
</CB_SEC_COMP>
Thanks for all answers. The problem was not with iPhone side. In server the XML was not correctly encoded to UTF8 string. When it correctly encoded I got valid arabic character. I only did code like
NSString* lableText = [[NSString alloc] initWithData:serverSentData encoding: NSUTF8StringEncoding ];
for converting NSData to NSString and it worked well!!!
这篇关于阿拉伯字符的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!