Re: Non ASCII characters in CFString litteral, HELP !



Sean McBride <cwatson@xxxxxxx> wrote:
In article <1172720951.797048@xxxxxxxxxxxxxxxxxx>,
Michael Ash <mike@xxxxxxxxxxx> wrote:

As others have said, the problem is gcc. Other than the workarounds
already suggested, you might look at using another compiler. Your
choices are: CodeWarrior (discontinued, thus not recommended), icc (from
Intel), and xlc (from IBM). I don't know if any of them accept
better-than-ASCII source files.

xlc is PPC-only and last I heard it did not do Objective-C. Same for icc
except it's x86-only. CodeWarrior is PPC-only and very dead, although it
does Objective-C, but I don't know if it does it convincingly enough to
actually work with Cocoa.

Oh, and they're all quite expensive, particularly compared to gcc's $free.

I think this is swatting a fly with a machine gun....

Maybe, that's for the OP to decide. Just trying to suggest options....

Also, you might not think it such a drastic solution if you couldn't
code in your mother tongue. Imagine gcc were a Japanese invention and
did not support English characters! :)

I would be careful calling it a "solution" when it doesn't actually fix
the OP's problem. The problem is non-ASCII NSString literals (the error
refers to CF but actually means both CF and NS) but one or two of the
compilers listed don't even support Objective-C. The one that does
(CodeWarrior) probably doesn't reliably support non-ASCII NSString
literals anyway. Even if it did, it won't support characters outside of
MacRoman because of how NSConstantString is implemented.

It is 2007 after all, and gcc's ASCII-only-ness is exceeding lame.

For this particular case, blame C or Cocoa, not gcc. Gcc is perfectly
happy to take C string constants in any encoding and just pass them
through to the other side. So as long as you make sure your files are
UTF-8 you can do something like this:

[NSString stringWithUTF8String:"Arbitrary Unicode Goes Here"]

However the C standard does not guarantee any particular behavior in this
case, so it's bad practice to rely on it in your code. Likewise, for ObjC
string constants, gcc just passes the data through. The problem is that
only MacRoman is accepted so for most people the data gets corrupted. It's
also not officially supported by the language/libraries, so once again
it's bad to rely on it. From what I can see, gcc is already doing as much
as it can in this department.

If you're referring to ASCII-only-ness outside of string constants (like
for identifiers and such), that certainly could be remedied and there's
little reason not to IMO, but once again the resulting code would be
unportable.

--
Michael Ash
Rogue Amoeba Software
.



Relevant Pages

  • Re: Non ASCII characters in CFString litteral, HELP !
    ... CodeWarrior is PPC-only and very dead, ... compilers listed don't even support Objective-C. ... It is indeed lamentable that we have pretty much only one compiler ... For this particular case, blame C or Cocoa, not gcc. ...
    (comp.sys.mac.programmer.help)
  • Re: math.nroot [was Re: A brief question.]
    ... > so before VC 7.1 was released (C99 ain't exactly new anymore). ... > support _some_ way to get at this stuff. ... This includes gcc before C99 ... > and fenv.h -- if the platforms represented in fpectlmodule.c were ...
    (comp.lang.python)
  • Re: Compiling Tcl with Msys/MinGW on Windows XP
    ... checking for gcc... ... checking whether the C compiler is a cross-compiler... ... checking for EXCEPTION_DISPOSITION support in include files... ... I saw one case were people had to use msys 1.0.6 ...
    (comp.lang.tcl)
  • Re: C is too old? opinions?
    ... You insisted that this pragma is supported by many compilers, ... I cannot find any mention of it in the documentation for my current gcc ... If they support if, it is undocumented and probably deprecated. ... And, of course, the bar software worked fine. ...
    (comp.lang.c)
  • Re: How Good is Processor Expert for DSP56800?
    ... >We are starting a design with the DSP56F8357 and using the CW support. ... Metrowerks is integrating into Freescale as a silicon enablement there ... are many exciting changes happening within Metrowerks role in Freescale. ... My job is ombudsman for CodeWarrior tools and I represent ...
    (codewarrior.embedded)