Skip to main content

Python bindings for wc(s)width

Project description

Python bindings for wc(s)width

cwcwidth provides Python bindings for wcwidth and wcswidth functions defined in POSIX.1-2001 and POSIX.1-2008 based on Cython. These functions compute the printable length of a unicode character/string on a terminal. The module provides the same functions as wcwidth and its behavior is compatible.

On systems not conforming to POSIX.1-2001 and POSIX.1-2008, Markus Kuhn's implementation is used to provide the functionality.

Dependencies

  • Cython >= 0.28 (optional, only for building). If Cython is not available, the C files are not regenerated from their source.

Quick installation guide

cwcwidth can be installed via pip:

pip install cwcwidth

or by running:

python3 setup.py install

Usage

>>> import cwcwidth
>>> cwcwidth.wcwidth("a")
1
>>> cwcwidth.wcswidth("コ")
2
>>> cwcwidth.wcswidth("コンニチハ, セカイ!")
19
>>> cwcwidth.wcswidth("コンニチハ, セカイ!", 5)
10

Comparison with wcwidth

>>> import wcwidth, cwcwidth, timeit
>>> timeit.timeit(lambda: wcwidth.wcswidth("コンニチハ, セカイ!"))
19.14463168097427
>>> timeit.timeit(lambda: cwcwidth.wcswidth("コンニチハ, セカイ!"))
0.16294104099506512

License

The code is licensed under the MIT license.

Tidelift

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coorindate the fix and disclosure.

Commercial support

cwcwidth and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cwcwidth, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size cwcwidth-0.1.4-cp36-cp36m-macosx_10_9_x86_64.whl (15.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp36-cp36m-manylinux1_i686.whl (51.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp36-cp36m-manylinux1_x86_64.whl (52.7 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp36-cp36m-manylinux2010_i686.whl (51.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp36-cp36m-manylinux2010_x86_64.whl (52.7 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp36-cp36m-win32.whl (18.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp36-cp36m-win_amd64.whl (20.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-macosx_10_9_x86_64.whl (15.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-manylinux1_i686.whl (52.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-manylinux1_x86_64.whl (53.9 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-manylinux2010_i686.whl (52.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-manylinux2010_x86_64.whl (53.9 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-win32.whl (18.3 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp37-cp37m-win_amd64.whl (20.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-macosx_10_9_x86_64.whl (15.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-manylinux1_i686.whl (54.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-manylinux1_x86_64.whl (56.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-manylinux2010_i686.whl (54.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-manylinux2010_x86_64.whl (56.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-win32.whl (18.6 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp38-cp38-win_amd64.whl (20.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-macosx_10_9_x86_64.whl (15.3 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-manylinux1_i686.whl (54.0 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-manylinux1_x86_64.whl (55.8 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-manylinux2010_i686.whl (54.0 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-manylinux2010_x86_64.whl (55.8 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-win32.whl (18.5 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4-cp39-cp39-win_amd64.whl (20.7 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size cwcwidth-0.1.4.tar.gz (11.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page