ulikoehler / UliPlot

After UliEngineering and UliAcceleration, the third library in the Uli series provides convient functions for plotting using matplotlib and other pydata libraries
https://techoverflow.net
Apache License 2.0
1 stars 0 forks source link

Full-width string length count wrong. #1

Open Chernfalin opened 3 years ago

Chernfalin commented 3 years ago

Some language use full-width char(Chinese/Japanes/Korean etc.) len() just show correctly in half-width language. Possible solution:

  1. provide encoding param, then count by len(string.encode('GBK'))...
  2. 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
ulikoehler commented 3 years ago

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 :-)