• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to code a NSString literal with UTF8?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >How to code a NSString literal with UTF8? (From: David Hoerl <email@hidden>)

  • Prev by Date: Re: Copyrighting Application Name
  • Next by Date: Re: Sharing preferences
  • Previous by thread: Re: How to code a NSString literal with UTF8?
  • Next by thread: Re: How to code a NSString literal with UTF8?
  • Index(es):
    • Date
    • Thread