Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Unicode Text in NSTableView?

Unicode Text in NSTableView?
Thread Tools
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Nov 30, 2003, 06:25 PM
 
I have an NSTableView that needs to display fractions using the Unicode single-character fractions such as "⅓" (instead of "1/3"). This appears to work correctly when the value is entered by the user. However, if I attempt to programatically automate the conversion of "1/3" to "⅓", I just get some other strange symbol displayed in the table instead.

This occurs in other situations as well, not just NSTableView.

How do I get it to use the character I want? I guess that somewhere I need to specify some encoding, but I'm unsure where. The source code file is encoded in Unicode (UTF-8), and that's where the program gets the character from.

The table (cell) appears to handle unicode fine when entered manually by a user.

How do I get it to work programatically?
     
Uncle Skeleton
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Nov 30, 2003, 07:40 PM
 
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Nov 30, 2003, 08:36 PM
 
Originally posted by Uncle Skeleton:
http://forums.macnn.com/showthread.p...hreadid=179321

:(
Thank you that did the trick. In case anyone else looks here for the answer it is this...

The NSString contsant notation @"1/2" is only good for ASCII characters, despite the fact that NSStrings are fine with unicode, etc. The work around is to use something like:

[NSString stringWithCharacters:(unichar *)"\x00\xbd" length:1]
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Dec 2, 2003, 10:44 AM
 
I think you can encode a 2 byte unicode character directly using \unnnn, in case you don't want to do a \xnn\xnn.
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:18 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,