On Sun, Apr 12, 2009 at 6:01 PM, John Joyce <dangerwillrobinsondan...@gmail.com> wrote: > Is there an easy way to take input (user or file based) at runtime and > convert unicode strings such as \u8D64 (UTF8 character) or a whole series of > these to the human-readable characters they represent? > I imagine I should be using NSScanner, but is there not some simple function > or method to lookup and return the character as it should be represented? > Happy to RTFM, just need a pointer to the docs I should be looking at.
Note that those are just unicode code points, not UTF-8 "characters", whatever that would be. There is nothing built-in that I know of to convert these. You can search the string using one of the built-in methods, and then read the number with NSScanner's -scanHexInt:. If you know that your code points will always be no more than 4 digits (16 bits), which I think would have to be the case because otherwise you wouldn't know where to stop scanning the number, then you can make a string out of it easily using the %C format specifier, like so: unsigned value; if([scanner scanHexInt:&value]) { NSString *str = [NSString stringWithFormat:@"%C", value]; ... put str back into the original string ... } else // couldn't parse the value Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com