• 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: Unicode and NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Unicode and NSTextView (From: Timothy Larkin <email@hidden>)

  • Prev by Date: FileWrapper from rtf or rtfd
  • Next by Date: Re: Updating menubars, what exactly does setMainMenu do?
  • Previous by thread: Re: Unicode and NSTextView
  • Next by thread: Re: Unicode and NSTextView
  • Index(es):
    • Date
    • Thread