• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString really Unicode?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 D ada
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.


  • Follow-Ups:
    • Re: NSString really Unicode?
      • From: Clark Cox <email@hidden>
    • Re: NSString really Unicode?
      • From: Ondra Cada <email@hidden>
References: 
 >Re: NSString really Unicode? (From: Ondra Cada <email@hidden>)

  • Prev by Date: How can I put an icon in NStabview button
  • Next by Date: Re: Clicking Dock Icon creates a new window
  • Previous by thread: Re: NSString really Unicode?
  • Next by thread: Re: NSString really Unicode?
  • Index(es):
    • Date
    • Thread