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

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


  • Follow-Ups:
    • Re: How to count composed characters in NSString?
      • From: "Michael Ash" <email@hidden>
    • Re: How to count composed characters in NSString?
      • From: Michael Gardner <email@hidden>
  • Prev by Date: Re: design pattern for data acquisition in background thread?
  • Next by Date: How to get the current screen resolution on Mac
  • Previous by thread: PubSub not automatically downloading enclosures
  • Next by thread: Re: How to count composed characters in NSString?
  • Index(es):
    • Date
    • Thread