• 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: UNICODE from a WinTel box
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UNICODE from a WinTel box


  • Subject: Re: UNICODE from a WinTel box
  • From: Finlay Dobbie <email@hidden>
  • Date: Wed, 4 Jan 2006 13:47:21 +0000

On 04/01/06, Kenny Millar <email@hidden> wrote:
> 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.

...

> So when I tried using [NSString stringWithCharacters:(unichar *)&data
> length:sizeof(data)] obviously the resulting string was garbled due to the
> inccorect endian-ness.

Well, the first issue is that length is the number of unichars, not
the size in bytes.

> 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?

Since you already know what endian the data you're receiving is, you
can probably assume it'll always be little-endian? On Tiger you can
use kCFStringEncodingUTF16LE to create a CFString, and CFString is
toll-free bridged with NSString.

 -- Finlay
 _______________________________________________
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

References: 
 >UNICODE from a WinTel box (From: "Kenny Millar" <email@hidden>)

  • Prev by Date: Re: Uniform Type Identifiers (UTIs)
  • Next by Date: IB problem reading header file
  • Previous by thread: Re: UNICODE from a WinTel box
  • Next by thread: Breakpoints in categories are ignored?
  • Index(es):
    • Date
    • Thread