• 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: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sun, 28 Sep 2008 12:53:46 +0200


On Sun, 28 Sep 2008 03:27:48 -0500, Michael Gardner <email@hidden> wrote:

On Sep 27, 2008, at 2:23 PM, David Niemeijer wrote:

Hi,

I have been trying to find this in the documentation and list
archives but without success so far. What is the best way to count
the number of characters in an NSString taking account of the fact
that some characters may take up multiple 16 bit slots. Using "-
(NSUInteger)length" is thus not the right way.

If I am reading you right, you are saying that -length will give you the wrong results because some characters in Unicode are represented by multibyte sequences. This is incorrect: -length will give you the number of Unicode characters in a string [...].

This surprises me. I always thought that "length" gives you the number of shorts in the Utf-16 encoding of the string, which - as I used to think - is not the same as the number of Unicode code points in this string.


But maybe you are right and I am confused.


Kind regards,

Gerriet.

_______________________________________________

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 Gardner <email@hidden>
  • Prev by Date: Re: Need to override +(Class) class?
  • Next by Date: Re: design pattern for data acquisition in background thread?
  • 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