5

How to get stroke count of Chinese character?

Example>

一 => 1

十 => 2

日 => 4

Makoto
  • 104,088
  • 27
  • 192
  • 230
ChangUZ
  • 5,380
  • 10
  • 46
  • 64
  • 2
    Can you use a lookup table? http://technology.chtsai.org/charfreq/characters.html – Gabe Sep 07 '11 at 04:11
  • 1
    See question [Programatically determine number of strokes in a chinese character](http://stackoverflow.com/questions/2398334/programatically-determine-number-of-strokes-in-a-chinese-character). – lschin Sep 08 '11 at 04:21

3 Answers3

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.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
0

You can use "ssc install cnstroke" STATA command for the said purpose.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Vikram Parimi Sep 11 '22 at 12:18
-1

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

Jerry Juang
  • 147
  • 2
  • 2