• 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: Nonbreaking spaces in alerts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nonbreaking spaces in alerts


  • Subject: Re: Nonbreaking spaces in alerts
  • From: "Sean McBride" <email@hidden>
  • Date: Wed, 19 Oct 2005 10:46:36 -0400
  • Organization: Rogue Research

On 2005-10-18 23:31, Elias Mårtenson said:

>> GCC isn't mangling the string. @"" is designed to take ASCII
>> encoding, not UTF8 or MacRoman or anything else. What you'll get
>> for any character above 127 is just undefined. Why Apple/NeXT chose
>> to make @"" work this way, I don't know, but that's the situation.
>
>No, it's not GCC that is mangling the string, it's whatever code runs
>when the @ is seen before a string. GCC itself delivers UTF-8 when it
>encounters a \u inside a string. Therefore the following works:
>
>(remember that you need the -std=c99 compiler option for this to work)
>
>NSString *s = [NSString stringWithUTF8String:"Mac\u00A0OS\u00A0X"];
>
>And yes, I just tried it myself. :-)

How lame it is that

NSString *s = [NSString stringWithUTF8String:"Mac\u00A0OS\u00A0X"];

is ok, but

NSString *s = @"Mac\u00A0OS\u00A0X";

is not.  But it's not gcc's fault.  The Objective-C documentation says:

"@"string" - Defines a constant NSString object in the current module
and initializes the object with the specified 7-bit ASCII-encoded string."

So the language is defined that way, the compiler must follow.  The
compiler can warn you though, with this option:

-fconstant-cfstrings

It will say "warning: non-ASCII character in CFString literal".

Of course our beloved xCode does not turn this on by default, nor does
it have any GUI option for it.  In fact, from the gcc man page, it
doesn't even seem to me that -fconstant-cfstrings is a warning option,
nevertheless it works if you put in 'other warning flags'.  I hope it
doesn't break something else! :)

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
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

  • Follow-Ups:
    • Re: Nonbreaking spaces in alerts
      • From: Elias Mårtenson <email@hidden>
    • Re: Nonbreaking spaces in alerts
      • From: John Stiles <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>)
 >Re: Nonbreaking spaces in alerts (From: Elias Mårtenson <email@hidden>)
 >Re: Nonbreaking spaces in alerts (From: John Stiles <email@hidden>)
 >Re: Nonbreaking spaces in alerts (From: Elias Mårtenson <email@hidden>)

  • Prev by Date: NSImageReps for CGImageRefs
  • Next by Date: Re: Best way to get NSImage for NSWindow?
  • Previous by thread: Re: Nonbreaking spaces in alerts
  • Next by thread: Re: Nonbreaking spaces in alerts
  • Index(es):
    • Date
    • Thread