Re: NSString really Unicode?
Re: NSString really Unicode?
- Subject: Re: NSString really Unicode?
- From: "James J. Merkel" <email@hidden>
- Date: Sat, 13 Mar 2004 06:22:15 -0800
Ok, I stand corrected on that. You can prepend the correct BOM and
read a LE string.
One more thing -- if you have a Unicode string aString, the following
will work:
[aString isEqualToString:@"Jim"]; -- even when aString uses, for
example, 16-bit characters while @"Jim" uses 7-bit ASCII characters.
Jim Merkel
On Mar 13, 2004, at 4:01 AM, Ondra Cada wrote:
James,
On Saturday, Mar 13, 2004, at 07:56 Europe/Prague, James J. Merkel
wrote:
NSString works with big endian Unicode strings only.
No, that's wrong. NSString imports equally well each endianness; BE is
just a default for improper Unicode strings without a BOM.
If you are reading a file that has little endian strings, you need to
do byte swapping before handing the string to an NSString method.
Presumed you got such a data, you can save effort and source lines by
just prepending the right BOM:
char buffer[SIZE+2]={0xff,0xfe};
fread(buffer+2,sizeof(char),length,fp);
...
---
Ondra Dada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.