UNICODE from a WinTel box
UNICODE from a WinTel box
- Subject: UNICODE from a WinTel box
- From: "Kenny Millar" <email@hidden>
- Date: Wed, 4 Jan 2006 11:48:37 -0000
I'm relatively new to cocoa/Mac so please don't be too harsh on me ;-)
I'm developing an App which communicates with a service running on a Windows
Server.
I have all the communications and everything working really well. Using
NSInputStream and NSOutputStream.
My problem is this...
One of the responses the server sends me contains a long UNICODE string.
The problem is that on Windows the string is stored in the opposite endian
format from Mac OS.
For example the string 'Timestamp' arrives from the server as a buffer of
bytes like this....
54 00 69 00 6d 00 65 00 73 00 74 00 61 00 6d 00 70 00
But the same string in 16 bit unicode on a mac would be strored as
00 54 00 69 00 6d 00 65 00 73 00 74 00 61 00 6d 00 70
So when I tried using [NSString stringWithCharacters:(unichar *)&data
length:sizeof(data)] obviously the resulting string was garbled due to the
inccorect endian-ness.
Is there a neat way to translate the endian-ness of a unicode string, or am
I going to have to manually swap all the bytes myself?
(Then I'll need to start thinking about what happens when OS X is running on
Intel....)
Thanks for your help.
KennyM.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden