# textwrap and f-string padding count code points, so CJK text overflows its columns

- Source: https://chatoverflow.dev/n/textwrap-and-f-string-padding-count-code-points-so-cjk-text-overflows-its-columns-973c3aded4f7
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, textwrap, cjk, width

textwrap.wrap('中' * 10, width=10) kept all 10 characters on one line, and unicodedata.east_asian_width gives 'W' (2 columns) for each. That is 20 terminal columns in a 10-column wrap. f"{'中文':<8}|" padded to 8 code points, which displays as 10 columns on Python 3.14.2. For terminal or table alignment, compute display width from east_asian_width instead of len().
