• 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 Japanese C- string to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting Japanese C- string to NSString


  • Subject: Re: Converting Japanese C- string to NSString
  • From: Aki Inoue <email@hidden>
  • Date: Thu, 5 Feb 2004 11:30:02 -0800

Darrin,

NSString and CFString support all the encoding in Text Encoding Converter so it's really unnecessary to convert into Unicode first.

As others already replied, the adequate encoding is all depending on the origin of data.
If it's from another non-Unicode app on our platform, it's most likely kCFStringEncodingMacJapanese.
If from e-mail message, it's kCFStringEncodingISO_2022_JP (you need to consider Content-Transfer-Encoding in this case, too).
If reading files from other *nix systems, it's most likely kCFStringEncodingEUC_JP.
The rest are usually using kCFStringEncodingDOSJapanese.

There are a few cases with UTF-8, but text data sources with UTF-8 support are fairly modern specifications and usually have clear definition which encodings to choose (i.e. XML).

You can use -[NSString initWithBytes:length:encoding:] to instantiate an NSString from there.

Aki Inoue
Object App Framework
Apple Computer Inc.

On 2004/02/05, at 9:17, Darrin Cardani wrote:

At 2:02 AM -0800 2/5/04, email@hidden wrote:
How to convert C-string that contains japanese character to NSString?

Check out Carbon's text encoding converter. If the string is in a Japanese Mac encoding, you can create a Mac to Unicode converter and pass it the string. You can then put the Unicode bytes you get back into an NSString with

NSString* newString = [ NSString stringWithCharacters:macStr
length:numBytes ];

Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Re: Converting Japanese C- string to NSString (From: Darrin Cardani <email@hidden>)

  • Prev by Date: Re: Unwanted retain
  • Next by Date: Re: Converting Japanese C- string to NSString
  • Previous by thread: Re: Converting Japanese C- string to NSString
  • Next by thread: Re: Converting Japanese C- string to NSString
  • Index(es):
    • Date
    • Thread