• 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: Tom Sutcliffe <email@hidden>
  • Date: Mon, 25 Aug 2003 11:56:41 +0100

On Friday, August 22, 2003, at 02:01 pm, Timothy Larkin wrote:

My application creates an attributed string containing some high unicode (> 0xFF) characters. I use [NSTextContainer setAttributedString:] to put this string into an NSTextView. The international characters do not display correctly. For instance, "\u014d" (o-macron) appears as "\u2248 \u00e7.

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.

Yes you can't reliably put non-ascii in @"".

You can however do [NSString stringWithUTF8String:"<unicode stuff>"] providing the source code file's encoding is set to utf8. For some reason C-strings (without the @) work OK while NS Constant strings don't. I find this more convenient than looking up character codes and stuff, although the other suggestions in this thread are equally effective.

If I type o-macron directly into the NSTextView, it appears correctly. Curiously, after that, the debugger can no longer print the string correctly. Apparently the debugger and NSTextView have different ideas about how to represent an NSString that contains high unicode characters.

No the debugger escapes non-ascii characters when it prints them to screen. If the debugger is displaying non-ascii directly (as you said it was above) that's because it's got confused, and it's only appearing to have the correct characters (because you can't put non ascii in @"").

Regards,

Tom
_______________________________________________
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: Re: Apple Help Interface Guidelines
  • Next by Date: NSString -> char* ?
  • Previous by thread: Re: Unicode and NSTextView
  • Next by thread: Account Info on any Process given the pid
  • Index(es):
    • Date
    • Thread