• 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: "Sean McBride" <email@hidden>
  • Date: Wed, 30 Mar 2005 13:18:57 -0500
  • Organization: Rogue Research

On 2005-03-30 08:59, Ali Ozer said:

>   NSString *s = [NSString stringWithUTF8String:"Long -- dash"];    //
>Not safe; you're at the mercy of any tools you use

As I understand it, the danger here is that the compiler has no way of
knowing the file's text encoding, right?  The compiler will have to
assume ASCII, MacRoman, UTF8, or whatever, and if it assumes wrong,
badness ensues.  (In the XCode IDE, a user can specify a file's encoding,
which helps.) And since ASCII is the common denominator, only 7bit
characters are 'safe'.  Correct?

>and the following is not allowed:
>
>   NSString *s = @"Long -- dash";    // Not allowed

"Not allowed" but still accepted by gcc 3.3 (and CW 9.4).  <rdar://4073313>

This I understand to be disallowed because it is so documented:
"@"string" - Defines a constant NSString object in the current module and
initializes the object with the specified 7-bit ASCII-encoded string."
Fair enough.

But am I the only one who thinks it should be allowed?  Apple could
change the Obj-C language to allow it.  I doubt much code would break.
Do people really depend on such strings being NSConstantStrings?  We'd
still have the problem of the compiler having to know/guess the file's
encoding, but that problem is always there.

--
____________________________________________________________
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: How to code a NSString literal with UTF8?
      • From: Nicko van Someren <email@hidden>
    • Re: How to code a NSString literal with UTF8?
      • From: Ali Ozer <email@hidden>
References: 
 >Re: How to code a NSString literal with UTF8? (From: Ali Ozer <email@hidden>)

  • Prev by Date: Re: How to code a NSString literal with UTF8?
  • Next by Date: Re: how to make an object with a single unique instance like NSNull?
  • 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