How to get stroke count of Chinese character?
How to get stroke count of Chinese character?
Example开发者_StackOverflow社区>
一 => 1
十 => 2
日 => 4
Short answer: You can't without a hardcoded map of characters to stroke counts. And then, you'll have to assume the user is using a particular Chinese variant (e.g. traditional.)
Unicode (the basic character set used by NSString
) doesn't distinguish between traditional, simplified, Japanese-specific, Korean-specific, etc. hanzi. Unicode does not encode stroke information directly. Rather, it distinguishes between characters (not their graphical representations) and a character may have different stroke counts depending on language and font used. So while the character 十 may universally have two strokes, other characters will vary.
The example Wikipedia gives is the character for "grass", U+8279, which has four strokes in traditional Chinese, but 3 in every other variant.
You can use "ssc install cnstroke" STATA command for the said purpose.
Thanks, math.
First, call
NSInteger section = [[UILocalizedIndexedCollation currentCollation] sectionForObject:yourObject collationStringSelector:@selector(objectsProperty)];
then check index of section in following array
[UILocalizedIndexedCollation currentCollation].sectionTitles
Remember to add
Localized resources can be mixed = YES
in info.plist
精彩评论