• 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: do i have to convert each unichar on ppc and intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do i have to convert each unichar on ppc and intel


  • Subject: Re: do i have to convert each unichar on ppc and intel
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 30 Apr 2008 17:58:38 +0200


Le 30 avr. 08 à 17:24, Nick Rogers a écrit :

hi,
I'm using:
[NSString stringWithCharacters:gptEntry.partName length:36];
where gptEntry struct have been filled in from the disk.
The string shows correct on ppc, while shows garbage on intel.
So how can I convert an entire such unichar array to correct-endian format?
Is there any built-in support?


Thanks,
Nick


Note this quote from the documentation:

“When creating an NSString object from a UTF-16-encoded string (or a byte stream interpreted as UTF-16), if the byte order is not otherwise specified, NSStringassumes that the UTF-16 characters are big-endian, unless there is a BOM (byte-order mark), in which case the BOM dictates the byte order. When creating anNSString object from an array of Unicode characters, the returned string is always native-endian, since the array always contains Unicode characters in native byte order.”

If you create your string from the disk, you may use the function

+stringWithContentsOfFile:usedEncoding:error:
or
-initWithContentsOfFile:usedEncoding:error:

And if you want to create your string from a character array (and not from a file), I think you can use the -initWithBytes:length:encoding: method passing NSUnicodeStringEncoding as parameter. It may try to use the BOM in this case, as the encoding parameter do not specified it.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >do i have to convert each unichar on ppc and intel (From: Nick Rogers <email@hidden>)

  • Prev by Date: do i have to convert each unichar on ppc and intel
  • Next by Date: Re: Is there any compression library for Cocoa?
  • Previous by thread: do i have to convert each unichar on ppc and intel
  • Next by thread: [MEET] May CocoaHeads Mac Developer Meetings
  • Index(es):
    • Date
    • Thread