Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ascii text and unicode



Hi,

You have declared the string japan as const char*, so I assume you are using a 2-byte encoding (MacJapanese/Shift-JIS/EUC).
You need to tell CFStringCreateWithString that you are using this encoding.

Your editor has probably placed the MacJapanese codes for "日本" into the source file, so the character array is most likely to be MacJapanese. An easy way to see if the byte array is UTF-8 or a 2-byte encoding is to add a line:

size_t encodedSize = strlen( japan );

and use a debugger (or printf() ) to see what value goes into encodedSize. For UTF-8, this should be 7 bytes (3 bytes for each character, and one byte NUL). for any 2-byte encoding it will be 5 bytes (2 bytes for each character and one byte NUL), and for UTF16 it will be 6 bytes (2 bytes per character, 2 byte null).

My guess is that your code will work if you change the creation line to:

CFStringRef cfStr = ::CFStringCreateWithCString (NULL, japan, kCFStringEncodingMacJapanese);

Hope this helps.
--
Kristian

On 29 Jul 2004, at 23:39, Norio Ota wrote:

const char* japan = "日本";
CFStringRef cfStr = ::CFStringCreateWithCString (NULL, japan, kCFStringEncodingUTF8);

And how should I append this object, if it returns a proper object, to normal ascii text?

Thank you and best regards,
norio ota
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.


References: 
 >Ascii text and unicode (From: Norio Ota <email@hidden>)
 >Re: Ascii text and unicode (From: Frederick Cheung <email@hidden>)
 >Re: Ascii text and unicode (From: Norio Ota <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.