I wasted quite a bit of time to get some unicode into an NSString. My preferred way would have been @"This is a checkmark: \u2714" but that didn't work. I am too lame to hand code it in UTF8, which I should know but I actually don't. Eventually I used -initWithCharacters:length:.
Boring...
Comments (4)
Why not:
[NSString stringWithString:NSLocalizedStringFromTable(@"My Unicode String I live and die for",@"My Unicode Table",@"Yes this solution sucks a bit")];
and a My Unicode Table.strings file not localized in fact.
Posted by Stephane | August 4, 2004 11:53 AM
Posted on August 4, 2004 11:53
Nat's definitely right, this really is something which belongs into gcc - at least in the year 2004. I've stumbled across this earlier and chose the way Stephane proposes also. IMO there's no other portable way of achieving this.
Posted by znek | August 4, 2004 12:41 PM
Posted on August 4, 2004 12:41
I don't like that solution that much because I have now that .strings file just for this problem. My code is in a framework, which I just feel the application will have a problem locating the .strings file at the opportune moment.
Posted by Nat! | August 5, 2004 8:50 PM
Posted on August 5, 2004 20:50
What about: [NSString stringWithFormat:@"String with unicode %C", (unichar) 0x2714] ?
Posted by Stefan Kreutter | January 20, 2005 2:21 PM
Posted on January 20, 2005 14:21