Problem solved: Dealing with non-standard character sets...
Problem solved: Dealing with non-standard character sets...
- Subject: Problem solved: Dealing with non-standard character sets...
- From: Michael Heinz <email@hidden>
- Date: Sat, 8 Oct 2005 11:46:35 -0400
Well, that turned out to be a lot easier than I thought (although I'm
a little worried about buffer over runs). I'm also weirded out by how
unichar doesn't seem to be defined or discussed anywhere in the
documentation and doesn't seem to be a built-in type either (at
least, XCode doesn't treat the word "unichar" the same way it does
"unsigned char").
For anyone curious the final code is below. It's not exactly high
performance, but it works. I solved the "what font" issue by setting
the font of the NS* objects in question to Apple Symbol.
Thank you to everyone who helped me out.
-----------
static unsigned short uniCharMap[256] = {
0xffff,
0xffff,
......
0x25a6,
.....
0x2193,
... etc., etc.,
)
....
+ (NSString *)convertStringtoUnicode: (const unsigned char *)string
{
NSMutableString *uniString = [[NSMutableString alloc] init];
int i;
for (i=0;string[i];i++) {
unichar c = string[i];
unichar uc = uniCharMap[c];
if (uc == 0xffff) {
[uniString appendString: [NSString
stringWithCharacters:&c length:1]];
} else {
[uniString appendString: [NSString
stringWithCharacters:&uc length:1]];
}
}
return uniString;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden