• 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: How to display Japanese in debug console?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to display Japanese in debug console?


  • Subject: Re: How to display Japanese in debug console?
  • From: Damien Bobillot <email@hidden>
  • Date: Sun, 25 Jun 2006 11:54:18 +0200

Norio Ota wrote :

Would you tell me how to display Japanese on the debug console window?

// the content in the quotation mark is actually Japanese.
fprintf ( stderr, "Nihongo string here" );  // it works.

It works because your source file is encoded in UTF8, and the console window expects UTF8 characters.

// the following codes don't work. The string in the quotation is also Japanese.
char * c_str = "Nihongo".
fprintf ( stderr, "%s\n", c_str ); // not work.

I think this code is not in the same file as the previous one. If the file is encoded with UTF8, it should work.

CFStringRef cfRef = CFStringCreateWithCString (NULL, c_str, CFStringGetSystemEncoding());

There's an error here : never use CFStringGetSystemEncoding() in this situation ! Your string is hard coded in the binary, so it has a precise encoding. The user may change the system default encoding, so it will be a chance that he choose the good one.

The good way to do that is to also hardcode the encoding. If your source file is encoded with UTF8, use kCFStringEncodingUTF8.

CFShow (cfRef); // not work

CFShow convert all non-ascii characters to "\uXXXX", so it's not a good choice for such tests. You may use the Cocoa NSLog instead (and link against the Cocoa framework).

CFRelease ( cfRef);

Here's a test I ran successfully (with greek characters encoded in UTF8) :
fprintf(stderr, "λαμβδα\n");
char * c_str = "λαμβδα bis";
fprintf ( stderr, "%s\n", c_str );
CFStringRef cfRef = CFStringCreateWithCString(NULL, c_str, kCFStringEncodingUTF8);
NSLog(cfRef);
CFRelease(cfRef);

-- 
Damien Bobillot

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How to display Japanese in debug console? (From: Norio Ota <email@hidden>)

  • Prev by Date: How to display Japanese in debug console?
  • Next by Date: Re: How to display Japanese in debug console?
  • Previous by thread: How to display Japanese in debug console?
  • Next by thread: Re: How to display Japanese in debug console?
  • Index(es):
    • Date
    • Thread