• 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: Displaying characters from the 'Unicode Symbols' font ?? (Solved)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying characters from the 'Unicode Symbols' font ?? (Solved)


  • Subject: Re: Displaying characters from the 'Unicode Symbols' font ?? (Solved)
  • From: Anders Lassen <email@hidden>
  • Date: Fri, 25 Sep 2009 21:17:28 +0200

Thanks everyone for helping.

This solved my problem on how to handle characters outside the 16 bits range.

Anders Lassen

On Sep 25, 2009, at 8:57 PM, Aki Inoue wrote:

The Unicode values beyond 16bit range are represented with a pair of UTF-16 characters in U+D800 ~ U+DFFF.

See relevant items in <http://unicode.org/glossary/#S> for the definitions.

There are several ways to insert UTF-32 values into NSString.
Doug mentioned some.

The easiest is to use the C99 universal character name.

For example, U+1D400 can be represented with @"\U0001D400" using compliers shipped with Xcode 3.0 or later.

Another approach is to use an array of UTF-32 characters and convert with NSUTF32StringEncoding.

UTF32Char character = 0x0001D400;
#if __BIG_ENDIAN__
NSStringEncoding encoding = NSUTF32BigEndianStringEncoding;
#else
NSStringEncoding encoding = NSUTF32LittleEndianStringEncoding;
#endif
NSString *string = [[NString alloc] initWithBytes:&character length:sizeof(character) encoding:encoding];


Or, you could fill a UTF-16 buffer and create from it using new inline functions introduced with SnowLeopard.
UniChar characters[2];
NSString *string;


CFStringGetSurrogatePairForLongCharacter(0x0001D400, characters);
string = [[NSString alloc] initWithCharacters:characters length:2];

Aki

On 2009/09/25, at 11:33, Anders Lassen wrote:

I have tried this but gave up, because I did not now of surrogate pairs.

But I will try again.

Anders Lassen

On Sep 25, 2009, at 8:27 PM, Douglas Davidson wrote:


On Sep 25, 2009, at 11:18 AM, Anders Lassen wrote:

But still, I can not see, how this solve my problem getting characters outside the unicode 16 bits range into a NSString.

NSString is conceptually UTF-16, which means that characters outside the BMP are represented using surrogate pairs. However, for purposes of getting them into an NSString, you can (for example) represent them in UTF-32 and use one of the conversion methods. Alternatively, you could put them in a file, maybe a text file or a plist, and let the standard import methods deal with encoding issues.


Douglas Davidson


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Displaying characters from the 'Unicode Symbols' font ?? (From: Anders Lassen <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Kyle Sluder <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Anders Lassen <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Douglas Davidson <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Anders Lassen <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Douglas Davidson <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Anders Lassen <email@hidden>)
 >Re: Displaying characters from the 'Unicode Symbols' font ?? (From: Aki Inoue <email@hidden>)

  • Prev by Date: Suggestions for debugging “EXC_BAD_ACCESS”
  • Next by Date: Re: Suggestions for debugging “EXC_BAD_ACCESS”
  • Previous by thread: Re: Displaying characters from the 'Unicode Symbols' font ??
  • Next by thread: Re: Displaying characters from the 'Unicode Symbols' font ??
  • Index(es):
    • Date
    • Thread