Skip to main content

CJKwrap is a library for wrapping and filling CJK text. Fix Python issue24665

Project description

CJKwrap is a library for wrapping and filling CJK text.

CJKwrap fix the issue24665 because Python2 will stay broken forever: https://bugs.python.org/issue24665.

CJKwrap support Python 2 (2.6 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

cjklen() and cjkslices() to replace built-in len() and slicing:

>>> import cjkwrap
>>> cjkwrap.cjklen(u"最終的には良い長さ")
18
>>> head, tail = cjkwrap.cjkslices(u"最終的には良い長さ",6)
>>> print head
最終的
>>> print tail
には良い長さ

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.

Project details


Download files

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

Source Distribution

CJKwrap-1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CJKwrap-1.0-py2-none-any.whl (4.2 kB view details)

Uploaded Python 2

File details

Details for the file CJKwrap-1.0.tar.gz.

File metadata

  • Download URL: CJKwrap-1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for CJKwrap-1.0.tar.gz
Algorithm Hash digest
SHA256 8d2f9266f97696edb0a50efbea7bbca7df846bacae29e8eb2c77dcb051999ef7
MD5 5f8d7ce58efd1e664489589a39f7015c
BLAKE2b-256 3698de93f5d263a85eb4369ba9449b7899a0e046dbc060c8d2205d687c369cc1

See more details on using hashes here.

File details

Details for the file CJKwrap-1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for CJKwrap-1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 d4f029425c99d6c22f3164dcf35eb0fb6763c6eede5b810f47ba842c1ebe18f0
MD5 dd73005debe2d6be94671f12f906ca9f
BLAKE2b-256 257655b1659a16aa72f87d33dd13f62ef6bc21c9b88257d6e1bf99bbac3c25dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page