Re: unexpected unicode behavior
Re: unexpected unicode behavior
- Subject: Re: unexpected unicode behavior
- From: Aki Inoue <email@hidden>
- Date: Fri, 25 May 2007 09:23:08 -0700
Daniel,
radicals[i] is pointing an NSString object.
For logging an object's description, you can use %@.
So, in order to get something like "0x2F00 一",
You need "0x%X %@" as your format string.
Aki
Hi All,
I am trying to populate an array with Chinese radicals. Here's what
I tried:
#define FIRST_RADICAL 0x2F00
#define LAST_RADICAL 0x2FD5
#define NUM_RADS ((LAST_RADICAL - FIRST_RADICAL) + 1)
....
unichar radCodePoints[NUM_RADS];
NSString *radicals[NUM_RADS];
float unicodeValue;
unicodeValue = FIRST_RADICAL;
for (i = 0; i <= NUM_RADS; i++)
{
radCodePoints[i] = unicodeValue;
radicals[i] = [NSString stringWithCharacters: &radCodePoints[i]
length: 1];
NSLog(@"%C %C", radCodePoints[i], radicals[i]);
unicodeValue++;
}
The NSLog I used to check what was going on produced weird results.
I was expecting something like:
0x2F00 一
0x2F01 ⼁
0x2F03 ⼂ etc.
but instead got:
⼀ 源
⼁ 祀
⼂ 祐
In other words, the first one was not the float value but rather the
correct radical. I have no idea what the second character in each
row is. Some mystery character.
So I changed the NSLog to
NSLog(@"%X %S", radCodePoints[i], radicals[i]);
(where X is for hexadecimal and S is supposed to be for Unicode
strings). Now I get the correct Unicode code points (0x2F00 etc.)
but the second column is gibberish (ꁻ왴ސ for each row, and that
doesn't change.) Can someone explain what I'm doing wrong?
Thanks.
Daniel_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden