CJKwrap is a library for wrapping and filling CJK text.
CJKwrap fix the issue24665 because Python 2 will stay broken forever: https://bugs.python.org/issue24665.
CJKwrap support both Python 2 (2.6 and above) and Python 3 (3.3 and above).
CJKwrap is developed by Florent Gallaire fgallaire@gmail.com.
Website: http://fgallaire.github.io/cjkwrap.
Download and Install
To install the last stable version from PyPI:
$ sudo pip install cjkwrap
To install the development version from GitHub:
$ git clone https://github.com/fgallaire/cjkwrap $ cd cjkwrap $ sudo python setup.py install
Or you can just use the cjkwrap.py file alone, nothing more needed!
Usage
is_wide() to know if a char is double-width, cjklen() and cjkslices() to replace built-in len() and slicing:
>>> import cjkwrap >>> cjkwrap.is_wide(u"c") False >>> cjkwrap.is_wide(u"長") True >>> cjkwrap.cjklen(u"最終的には良い長さ") 18 >>> head, tail = cjkwrap.cjkslices(u"最終的には良い長さ", 6) >>> print(head) 最終的 >>> print(tail) には良い長さ
As cjklen() uses len() for non unicode stuff, you can safely do this:
>>> from cjkwrap import cjklen as len >>> len(u"最終的には良い長さ") 18 >>> len([1, 2, 3, 4]) 4
wrap() and fill() to replace the ones from the Python standard library:
>>> wrapped_cjk = cjkwrap.wrap(u"最終的に良いラッピング", 10) >>> for line in wrapped_cjk: print(line) ... 最終的に良 いラッピン グ >>> print(cjkwrap.fill(u"最終的に良いラッピング", 10)) 最終的に良 いラッピン グ
Mixed content is allowed:
>>> cjkwrap.cjklen(u"CJK 最終的には良い長さ") 22 >>> print(cjkwrap.fill(u"CJK 最終的には良い長さ", 10)) CJK 最終的 には良い長 さ
License
CJKwrap files are released under the GNU LGPLv3 or above license.
CJKwrap codebase from textwrap by Greg Ward (gward@python.net) under the Python license.
Metadata
Release files for CJKwrap 2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| CJKwrap-2.2.tar.gz | 21.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| CJKwrap-2.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 25.7 kB
Release files / CJKwrap-2.2.tar.gz
| Download URL | CJKwrap-2.2.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2c7d2e527a0e89865ac2e6e73f198b829b871c826f34eeb4efb09669e1ec0ac
|
|
BLAKE2b-256 checksum How to use checksums |
43e76289123edb86eef09d43ece0648c2eb71d860f020ae17b2c7a52ffa8bbe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / CJKwrap-2.2-py2.py3-none-any.whl
| Download URL | CJKwrap-2.2-py2.py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b756d0aaf5a3e765eefb7e6f9e5d47335e7d593fecfb201cdeb3c0f05ff47f0e
|
|
BLAKE2b-256 checksum How to use checksums |
70a8311665d8fd10f167b492b5363715c5bc262de0c39879a1ffba710f1a42ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for CJKwrap 2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.