开发者

iPhone socket stream content conversion problem from bytes to arabic

开发者 https://www.devze.com 2023-02-12 14:33 出处:网络
I need to read an XML from socket which is having mixed content of arabic and english. my problem is that when I am converting the received bytes in UTF-8, I am gett开发者_如何学Cing the english conte

I need to read an XML from socket which is having mixed content of arabic and english. my problem is that when I am converting the received bytes in UTF-8, I am gett开发者_如何学Cing the english content properly but arabic content is seems junk.

Any help is highly appreciated.

Regards, rohit


Alright expert,

I got the solution to my problem :)

The problem relies on the desktop server part.

Actually I was passing the Arabic String from my desktop Java application using DataOutputStream with method writeUTF() which is actually sending the the header containing the length of the data using writeShort() implicitly. So on the iPhone part, when I was using [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] ;

which is creating problem.

when I started to send data by write(byte[]) it worked!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号