How to count composed characters in NSString?
How to count composed characters in NSString?
- Subject: How to count composed characters in NSString?
- From: David Niemeijer <email@hidden>
- Date: Sat, 27 Sep 2008 21:23:25 +0200
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. Using a series of calls
to "rangeOfComposedCharacterSequenceAtIndex:" seems like a
possibility, but I am not sure this would be the most efficient way.
Is there a simple and straightforward solution? I would like to be
able to display the number of characters in a string and not report
the wrong results for foreign languages (which I would get if I simply
took the length of the string). I need a solution that does not only
work in Leopard (i.e. CFStringTokenizer is not an option) and that
does not require using the lower level UCFindTextBreak.
Thanks,
david.
_______________________________________________
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