• 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
String conversion help.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

String conversion help.


  • Subject: String conversion help.
  • From: John Draper <email@hidden>
  • Date: Thu, 23 Jun 2005 00:03:57 -0700

Hi,

I have a string containing 16 bit characters. They are called UTF16 type
strings.

I know that NSString has "stringWithUTF8String" class methods, but
I don't see any class methods that can construct a NSString,  given
a pointer to a buffer of characters of 16 bits in length (u_shorts)
or what I believe to be UTF16 type string encodings.

Can someone point me to the best way of constructing a NSString
from  memory that might look like this:

"abc" is stored as:

{ 0x00, 0x61, 0x00, 0x62, 0x00, 0x63 }  (Big Endian byte order)

And I want to use this as input in creating an NSString = @"abc".

I hope I explained this right.

I also want to be able to go the other way...   IE:  Given an NSString,
and a pointer to a buffer big enough to hold it,  return the data in
UTF16 encoding in the buffer.  Obviously, the buffer allocated would have
to be twice the size of the string plus 2 more bytes for the NULL at
the end.

The only encodings I see supported on the mac are:

NSASCIIStringEncoding
NSNEXTSTEPStringEncoding
NSUnicodeStringEncoding
NSISOLatin1StringEncoding
NSISOLatin2StringEncoding
NSSymbolStringEncoding

I have NO CLUE which of these is similar to UTF16 encodings?  I tried
"NSUnicodeStringEncoding" and that seemed to be the most likely one,
but BOY was I wrong.  I sure can use some tips here.

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


  • Follow-Ups:
    • Re: String conversion help.
      • From: j o a r <email@hidden>
  • Prev by Date: 1 NSScroller, multiple NSTextViews
  • Next by Date: Link C library in Cocoa.
  • Previous by thread: Re: 1 NSScroller, multiple NSTextViews
  • Next by thread: Re: String conversion help.
  • Index(es):
    • Date
    • Thread