On Sun, 28 Sep 2008 03:27:48 -0500, Michael Gardner <[EMAIL PROTECTED]> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to