wcwidth: Unicode String Width Measurement

0.6.0 · active · verified Sat Mar 28

wcwidth is a Python library that measures the displayed width of Unicode strings in a terminal, ensuring accurate text formatting. The current version is 0.6.0, released on January 22, 2022. The library is actively maintained with a release cadence of approximately every few months.

Warnings

Install

Imports

Quickstart

This example demonstrates how to import the wcwidth function and use it to measure the width of a Unicode string.

from wcwidth import wcwidth

# Measure the width of a Unicode string
text = 'Hello, 世界'
width = wcwidth(text)
print(f'The width of the text is: {width}')

view raw JSON →