xkdkxdxc
xkdkxdxc

Reputation: 511

Programmatically determine number of strokes in a Chinese character?

Does Unicode store stroke count information about Chinese, Japanese, or other stroke-based characters?

Upvotes: 12

Views: 3553

Answers (6)

Mark K
Mark K

Reputation: 9338

Can also use the library "strokes".

https://github.com/liao961120/strokes

from strokes import strokes

strokes('众')
6
strokes('众人')
[6, 2]

Upvotes: 0

cburgmer
cburgmer

Reputation: 2220

In Python there is a library for that:

>>> from cjklib.characterlookup import CharacterLookup
>>> cjk = CharacterLookup('C')
>>> cjk.getStrokeCount(u'日')
4

Disclaimer: I wrote it

Upvotes: 3

Tim
Tim

Reputation: 9259

A little googling came up with Unihan.zip, a file published by the Unicode Consortium which contains several text files including Unihan_RadicalStrokeCounts.txt which may be what you want. There is also an online Unihan Database Lookup based on this data.

Upvotes: 12

Joe Pitz
Joe Pitz

Reputation: 2464

If you want to do character recognition goggle HanziDict.

Also take a look at the Unihan data site:

http://www.unicode.org/charts/unihanrsindex.html

You can look up stroke count and then get character info. You might be able to build your own look up.

Upvotes: 2

paxdiablo
paxdiablo

Reputation: 881053

You mean, is it encoded somehow in the actual code point? No. There may well be a table somewhere you can find on the net (or create one) but it's not part of the Unicode mandate to store this sort of metadata.

Upvotes: 2

Related Questions