Open Chernfalin opened 3 years ago
Some language use full-width char(Chinese/Japanes/Korean etc.) len() just show correctly in half-width language. Possible solution:
def get_han_count(text): count = 0 for char in text: if unicodedata.east_asian_width(char) in 'FWA': count += 2 else: count += 1 return count
Thank you ! I will try to have a look and attempt to merge the fix later this week. I really appreciate you reporting this issue :-)
Some language use full-width char(Chinese/Japanes/Korean etc.) len() just show correctly in half-width language. Possible solution:
def get_han_count(text): count = 0 for char in text: if unicodedata.east_asian_width(char) in 'FWA': count += 2 else: count += 1 return count