Re: Non ASCII characters in CFString litteral, HELP !
- From: Michael Ash <mike@xxxxxxxxxxx>
- Date: Sun, 04 Mar 2007 16:52:20 -0600
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
.
- Follow-Ups:
- Re: Non ASCII characters in CFString litteral, HELP !
- From: Sean McBride
- Re: Non ASCII characters in CFString litteral, HELP !
- References:
- Re: Non ASCII characters in CFString litteral, HELP !
- From: Sean McBride
- Re: Non ASCII characters in CFString litteral, HELP !
- From: Michael Ash
- Re: Non ASCII characters in CFString litteral, HELP !
- From: Sean McBride
- Re: Non ASCII characters in CFString litteral, HELP !
- Prev by Date: Re: How to scroll using the keyboard?
- Next by Date: Re: How do I know when the user scrolled my NSScrollView?
- Previous by thread: Re: Non ASCII characters in CFString litteral, HELP !
- Next by thread: Re: Non ASCII characters in CFString litteral, HELP !
- Index(es):
Relevant Pages
|
|