Re: Unicode and NSTextView
Re: Unicode and NSTextView
- Subject: Re: Unicode and NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Fri, 22 Aug 2003 09:27:18 -0700
On Friday, August 22, 2003, at 06:01 AM, Timothy Larkin wrote:
I get the o-macron into the string by inserting an NSString constant.
Since I can make o-macron directly with Pop-char, I define in the
source @"<o-macron>". This appears correctly in the source file. If
I print it in the debugger, it also looks right. I also get the
correct glyph if I po [NSTextView textStorage]. But the TextView, as
I said, shows something completely different.
The problem here is that your source file is not Unicode. In fact,
there is no particular defined encoding for your source files, and the
compiler does not really have a notion of encodings; where string
constants are concerned I believe it simply copies them byte-for-byte.
This makes @"" problematic when used with anything but ASCII. There
are several possibilities--for example, if your string should be
localizable, as tends to be the case for most non-ASCII text, then you
can put the Unicode string in a .strings file (UTF-16) with an ASCII
key. You can even do this with non-localizable strings. If you need
just a few characters, you can use e.g. [NSString
stringWithFormat:@"%C", 0x14d]. You can also use something like
unichar buff[] = {0x14d, ...} and [NSString
stringWithCharacters:length:].
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.