python-wcwidth
Port variant py38
Summary Measures number of terminal column cells (PY38)
Package version 0.2.5
Homepage https://github.com/jquast/wcwidth
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants py39
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 13 DEC 2020, 19:47:07 UTC
Port created 21 APR 2020, 01:22:25 UTC
Subpackage Descriptions
single |pypi_downloads| |codecov| |license| ============ Introduction ============ This library is mainly for CLI programs that carefully produce output for Terminals, or make pretend to be an emulator. **Problem Statement**: The printable length of *most* strings are equal to the number of cells they occupy on the screen ``1 charater : 1 cell``. However, there are categories of characters that *occupy 2 cells* (full-wide), and others that *occupy 0* cells (zero-width). **Solution**: POSIX.1-2001 and POSIX.1-2008 conforming systems provide `wcwidth(3)`_ and `wcswidth(3)`_ C functions of which this python module's functions precisely copy. *These functions return the number of cells a unicode string is expected to occupy.* Installation ------------ The stable version of this package is maintained on pypi, install using pip:: pip install wcwidth Example ------- **Problem**: given the following phrase (Japanese), >>> text = u'コンニチハ' Python **incorrectly** uses the *string length* of 5 codepoints rather than the *printible length* of 10 cells, so that when using the `rjust` function, the output length is wrong:: >>> print(len('コンニチハ')) 5 >>> print('コンニチハ'.rjust(20, '_')) _____コンニチハ By defining our own "rjust" function that uses wcwidth, we can correct this:: >>> def wc_rjust(text, length, padding=' '): :alt: MIT License
Configuration Switches (platform-specific settings discarded)
PY38 ON Build using Python 3.8 PY39 OFF Build using Python 3.9
Package Dependencies by Type
Build (only) python-pip:single:py38
autoselect-python:single:standard
Build and Runtime python38:single:standard
Download groups
main mirror://PYPIWHL/59/7c/e39aca596badaf1b78e8f547c807b04dae603a433d3e7a7e04d67f2ef3e5
Distribution File Information
beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784 30763 wcwidth-0.2.5-py2.py3-none-any.whl
Ports that require python-wcwidth:py38
python-prompt-toolkit:py38 Builds powerful interactive command lines (PY38)