• 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: How to count composed characters in NSString?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to count composed characters in NSString?


  • Subject: Re: How to count composed characters in NSString?
  • From: Michael Gardner <email@hidden>
  • Date: Sun, 28 Sep 2008 23:52:30 -0500

On Sep 28, 2008, at 1:17 PM, David Niemeijer wrote:

Michael,

On 28 sep 2008, at 14:41, Michael Gardner wrote:
Upon further investigation, I may be wrong. I based my assertion upon Apple's NSString documentation ("Returns the number of Unicode characters in the receiver"), and upon some quick tests I ran. But this reply made me look into the issue in greater depth.

I re-did my tests more throughly, and it does appear that -length returns the number of 16-bit words (code units), not the number of Unicode characters (code points), in the string. If this is true, I would call it a bug either in the code or in the documentation, which David should submit to Apple.

i think the docs are clear. In the discussion section for "length" it says: "The number returned includes the individual characters of composed character sequences, so you cannot use this method to determine if a string will be visible when printed or how long it will appear."

But composed character sequences aren't the problem; surrogate pairs are. Composed character sequences can be taken care of by using either -precomposedStringWithCanonicalMapping or - precomposedStringWithCompatibilityMapping. In my opinion, -length should take surrogate pairs into account, which is what the docs seem to imply.


-Michael
_______________________________________________

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


  • Follow-Ups:
    • Re: How to count composed characters in NSString?
      • From: "Michael Ash" <email@hidden>
    • Re: How to count composed characters in NSString?
      • From: "Clark S. Cox III" <email@hidden>
References: 
 >Re: How to count composed characters in NSString? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to count composed characters in NSString? (From: Michael Gardner <email@hidden>)
 >Re: How to count composed characters in NSString? (From: David Niemeijer <email@hidden>)

  • Prev by Date: [ann] MacCode code repository Release 1
  • Next by Date: Re: How to count composed characters in NSString?
  • Previous by thread: Re: How to count composed characters in NSString?
  • Next by thread: Re: How to count composed characters in NSString?
  • Index(es):
    • Date
    • Thread