« Anticipation, after all, is everything | Main | STOP THE UNHOLY RELEASE OF DOOM 3 »

Static Unicode in NSString

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)

Stephane:

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.

znek:

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.

Nat!:

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.

Stefan Kreutter:

What about: [NSString stringWithFormat:@"String with unicode %C", (unichar) 0x2714] ?

About

This page contains a single entry from the blog posted on August 3, 2004 11:27 PM.

The previous post in this blog was Anticipation, after all, is everything.

The next post in this blog is STOP THE UNHOLY RELEASE OF DOOM 3.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34