Using "textwrap" package for unwrappable languages (Japanese)

c.buhtz at posteo.jp c.buhtz at posteo.jp
Wed Aug 30 09:18:25 EDT 2023


Dear Peter,

thanks for your reply. That is a very interesting topic.

I was a bit wrong. I realized that textwrap.wrap() do insert linebreaks 
when "words" are to long. So even a string without any blank space well 
get wrapped.

Am 30.08.2023 14:07 schrieb Peter J. Holzer via Python-list:
> another caveat: Japanese
> characters are usually double-width. So (unless your line length is 130
> characters for English) you would want to add that line break every 32
> characters.

I don't get your calculation here. Original line length is 130 but for 
"double-with" characters you would break at 32 instead of 65 ?

> (

Then I will do something like this

     unicodedata.east_asian_width(mystring[0])

W is "wide". But there is also "F" (full-width).
What is the difference between "wide" and "full-width"?

My application do support (currently 46) languages including Simplified 
and Traditional Chinese, Vietnamese, Korean, Japanese, Cyrylic.


More information about the Python-list mailing list