• 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 and wchar_t
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString and wchar_t


  • Subject: Re: NSString and wchar_t
  • From: Sandy Martel <email@hidden>
  • Date: Tue, 18 Dec 2001 11:12:04 -0500

On Tuesday, December 18, 2001, at 10:08 AM, James Gregurich wrote:

What is the proper way to convert between wchar_t* and NSString/NSMutableString in Objective C++?

wchar_t is a unicode (double byte) character


no, wchar_t is four bytes with gcc...


To illustrate what I am after:


wchar_t *x = L"This is a string";



It seems that there is no way to get a wchar_t string in a CFString, I suppose its the same for a NSString.

If you know that the string just contain UTF16 data, you can strip the extra 2 bytes by copying it in a buffer of UInt16 and then call

myString = [NSString initWithData:dataBuffer encoding:NSUnicodeStringEncoding];

but if the string really contains UTF32 data, all I can see is use the Carbon TextConverter API to get the string in UTF16 encoding and then call the initWithData:encoding:.

If someone know a better way...let me know please

Sandy.


  • Follow-Ups:
    • Re: NSString and wchar_t
      • From: James Gregurich <email@hidden>
References: 
 >NSString and wchar_t (From: James Gregurich <email@hidden>)

  • Prev by Date: customizing TextView keyboard responses
  • Next by Date: Re: THANK YOU OSX GANG
  • Previous by thread: NSString and wchar_t
  • Next by thread: Re: NSString and wchar_t
  • Index(es):
    • Date
    • Thread