Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nonbreaking spaces in alerts



18 okt 2005 kl. 22.45 skrev John Stiles:

On Oct 18, 2005, at 1:38 PM, Elias Mårtenson wrote:

18 okt 2005 kl. 22.18 skrev Paul J. Lucas:


On Tue, 18 Oct 2005, John Stiles wrote:

Use option-space to make the non-breaking spaces. You can't use @"blah" for
this, since it's no longer ASCII, but you can load it as a localized string or
use stringWithUTF8String or something like that.

For the stringWithUTF8String, is there some Unicode code I can use inline, e.g., @"Mac&#xxxx;OS&#xxxx;X" ?

Yes, @"Mac\u00A0OS\u00A0X" should work.

Um, I don't think that will work. @"" strings only work with ASCII because there is no encoding specified. They might coincidentally work with MacRoman at present, but this is not guaranteed behavior, and the docs specifically warn against relying on this.

The \u notation is specified in C99, and it's certainly accepted by Apple's gcc when using the -std=c99 option. However, I was surprised to see that while the compiler accepted the code, the result wasn't what I had expected.


My guess is that gcc erroneously does in fact let the string pass through some locale encoding, even though it shouldn't. The \u notation is supposed to allow you to enter Unicode values in the code without having to worry about the encoding of the local system that runs the compile.

One thing you can do--try stringWithFormat. You can use %C to embed Unicode characters. Or you can put the UTF8 encoded text into a const char* buffer however you like (i.e. \x), and then use stringWithUTF8String.

Yes, under the circumstances this is the only safe way to achieve the desired result with any ease. However, I would like to stress that in most cases these strings are better put in separate strings files for easy localisation.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Nonbreaking spaces in alerts (From: "Paul J. Lucas" <email@hidden>)
 >Re: Nonbreaking spaces in alerts (From: John Stiles <email@hidden>)
 >Re: Nonbreaking spaces in alerts (From: "Paul J. Lucas" <email@hidden>)
 >Re: Nonbreaking spaces in alerts (From: Elias Mårtenson <email@hidden>)
 >Re: Nonbreaking spaces in alerts (From: John Stiles <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.