• 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: Converting wchar_t string to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting wchar_t string to NSString


  • Subject: Re: Converting wchar_t string to NSString
  • From: David Elliott <email@hidden>
  • Date: Sun, 8 Feb 2004 18:21:57 -0500

On Feb 8, 2004, at 5:35 PM, Glen Low wrote:

No, I do know the difference between encoding and character set. I thought it was clear from my message that I was using the wchar_t type (from Panther and Jaguar) and wcs* functions from Panther using a 4-byte (that is what wchar_t is on OS X after all) Unicode character set. Irrelevant to this discussion but worth noting is that at some point we intend to provide our own implementations of wcs* functions so that apps will run on Jaguar and presumably Puma as well. A wchar_t string in wxWindows is most certainly in the Unicode character set, now whether it is using UTF-32 or UCS-4 encoding I am unsure, supporting both would be nice. I will say it's using the wcs* functions to do all the work so whatever encoding the wcs* functions are using is what it's using.

Apologies. I was thinking of my Windows experience where sizeof (wchar_t) == 2, especially since it's only recently that proper wchar_t support was implemented on OS X where sizeof (wchar_t) == 4. Note that if wxWindows is using wchar_t from the Windows platform, sizeof (wchar_t) == 2 and that would be binary incompatible with OS X.

wxWindows uses the native char in "ANSI" mode and wchar_t in "Unicode" mode for wxString data. When writing to a file it's customary to use one of the built in conversion routines rather than dumping out data in the internal wxString format. If you don't use a conversion routine and try to access .c_str() then by golly you'll get what you asked for (native binary-incompatible data).

One other thing I forgot to ask. I'm told when using [NSString +stringWithCharacters:length:] I should pass it UTF-16 data. Does that hold true all the way back to OS 10.1?

-Dave
_______________________________________________
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: Converting wchar_t string to NSString
      • From: Andrew Thompson <email@hidden>
References: 
 >Re: Converting Japanese C- string to NSString (From: Darrin Cardani <email@hidden>)
 >Re: Converting Japanese C- string to NSString (From: John Stiles <email@hidden>)
 >Converting wchar_t string to NSString (From: David Elliott <email@hidden>)
 >Re: Converting wchar_t string to NSString (From: Glen Low <email@hidden>)
 >Re: Converting wchar_t string to NSString (From: Andrew Thompson <email@hidden>)
 >Re: Converting wchar_t string to NSString (From: David Elliott <email@hidden>)
 >Re: Converting wchar_t string to NSString (From: Glen Low <email@hidden>)

  • Prev by Date: Re: Document App or not?[little ot]
  • Next by Date: Re: What can I do with an NSRange in Objective-C?
  • Previous by thread: Re: Converting wchar_t string to NSString
  • Next by thread: Re: Converting wchar_t string to NSString
  • Index(es):
    • Date
    • Thread