Re: How to code a NSString literal with UTF8?
Re: How to code a NSString literal with UTF8?
- Subject: Re: How to code a NSString literal with UTF8?
- From: Nicko van Someren <email@hidden>
- Date: Wed, 30 Mar 2005 11:43:38 +0100
On 30 Mar 2005, at 04:17, David Hoerl wrote:
The Xcode editor lets you define a file encoding as UTF8. You can then
type in a line like:
NSString *foo = @"blah blah";
where blah blah have Unicode characters in them with encoded as UTF8.
But, when I ask this string for its characters I get garbage back, and
length is not correct.
What would the best way to do this be?
If you really want to hard-wire a Unicode string into your application
(e.g for odd glyphs like smilies or Apple command key characters) you
can use:
[NSString stringWithUTF8String: "blah blah"]; // Note that that is a C
"" string, not an @""
If however you want to include international text in your application
you are probably better off using:
NSLocalizedString(@"key string", @"default" );
Then you can put the unicode text into Localizable.strings under the
"key string" key and have different values for each language.
Cheers,
Nicko
_______________________________________________
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