CJKwrap
=======
**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.
Raw data
{
"_id": null,
"home_page": "https://fgallaire.github.io/cjkwrap",
"name": "CJKwrap",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "cjk wrap",
"author": "Florent Gallaire",
"author_email": "fgallaire@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/43/e7/6289123edb86eef09d43ece0648c2eb71d860f020ae17b2c7a52ffa8bbe9/CJKwrap-2.2.tar.gz",
"platform": "UNKNOWN",
"description": "CJKwrap\n=======\n\n**CJKwrap** is a library for wrapping and filling CJK text.\n\nCJKwrap fix the issue24665 because Python 2 will stay broken forever:\nhttps://bugs.python.org/issue24665.\n\nCJKwrap support **both** Python 2 (2.6 and above) and Python 3 (3.3 and above).\n\nCJKwrap is developed by Florent Gallaire fgallaire@gmail.com.\n\nWebsite: http://fgallaire.github.io/cjkwrap.\n\nDownload and Install\n--------------------\n\nTo install the last stable version from PyPI::\n\n $ sudo pip install cjkwrap\n\nTo install the development version from GitHub::\n\n $ git clone https://github.com/fgallaire/cjkwrap\n $ cd cjkwrap\n $ sudo python setup.py install\n\nOr you can just use the ``cjkwrap.py`` file alone, nothing more needed!\n\nUsage\n-----\n\n``is_wide()`` to know if a char is double-width, ``cjklen()`` and ``cjkslices()`` to replace built-in ``len()`` and slicing::\n\n >>> import cjkwrap\n >>> cjkwrap.is_wide(u\"c\")\n False\n >>> cjkwrap.is_wide(u\"\u9577\")\n True\n >>> cjkwrap.cjklen(u\"\u6700\u7d42\u7684\u306b\u306f\u826f\u3044\u9577\u3055\")\n 18\n >>> head, tail = cjkwrap.cjkslices(u\"\u6700\u7d42\u7684\u306b\u306f\u826f\u3044\u9577\u3055\", 6)\n >>> print(head)\n \u6700\u7d42\u7684\n >>> print(tail)\n \u306b\u306f\u826f\u3044\u9577\u3055\n\nAs ``cjklen()`` uses ``len()`` for non unicode stuff, you can safely do this::\n\n >>> from cjkwrap import cjklen as len\n >>> len(u\"\u6700\u7d42\u7684\u306b\u306f\u826f\u3044\u9577\u3055\")\n 18\n >>> len([1, 2, 3, 4])\n 4\n\n``wrap()`` and ``fill()`` to replace the ones from the Python standard library::\n\n >>> wrapped_cjk = cjkwrap.wrap(u\"\u6700\u7d42\u7684\u306b\u826f\u3044\u30e9\u30c3\u30d4\u30f3\u30b0\", 10)\n >>> for line in wrapped_cjk: print(line)\n ... \n \u6700\u7d42\u7684\u306b\u826f\n \u3044\u30e9\u30c3\u30d4\u30f3\n \u30b0\n >>> print(cjkwrap.fill(u\"\u6700\u7d42\u7684\u306b\u826f\u3044\u30e9\u30c3\u30d4\u30f3\u30b0\", 10))\n \u6700\u7d42\u7684\u306b\u826f\n \u3044\u30e9\u30c3\u30d4\u30f3\n \u30b0\n\nMixed content is allowed::\n\n >>> cjkwrap.cjklen(u\"CJK \u6700\u7d42\u7684\u306b\u306f\u826f\u3044\u9577\u3055\")\n 22\n >>> print(cjkwrap.fill(u\"CJK \u6700\u7d42\u7684\u306b\u306f\u826f\u3044\u9577\u3055\", 10))\n CJK \u6700\u7d42\u7684\n \u306b\u306f\u826f\u3044\u9577\n \u3055\n\nLicense\n-------\n\nCJKwrap files are released under the GNU LGPLv3 or above license.\n\nCJKwrap codebase from textwrap by Greg Ward (gward@python.net) under the Python license.\n",
"bugtrack_url": null,
"license": "GNU LGPLv3+",
"summary": "CJKwrap is a library for wrapping and filling CJK text. Fix Python issue24665",
"version": "2.2",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://fgallaire.github.io/cjkwrap"
},
"split_keywords": [
"cjk",
"wrap"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "70a8311665d8fd10f167b492b5363715c5bc262de0c39879a1ffba710f1a42ff",
"md5": "ff968b9de740c6319b9668769bfbbda7",
"sha256": "b756d0aaf5a3e765eefb7e6f9e5d47335e7d593fecfb201cdeb3c0f05ff47f0e"
},
"downloads": -1,
"filename": "CJKwrap-2.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "ff968b9de740c6319b9668769bfbbda7",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 4294,
"upload_time": "2016-12-27T06:19:51",
"upload_time_iso_8601": "2016-12-27T06:19:51.510025Z",
"url": "https://files.pythonhosted.org/packages/70/a8/311665d8fd10f167b492b5363715c5bc262de0c39879a1ffba710f1a42ff/CJKwrap-2.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "43e76289123edb86eef09d43ece0648c2eb71d860f020ae17b2c7a52ffa8bbe9",
"md5": "b1300ddfae18a7604aa039c1510bb82d",
"sha256": "a2c7d2e527a0e89865ac2e6e73f198b829b871c826f34eeb4efb09669e1ec0ac"
},
"downloads": -1,
"filename": "CJKwrap-2.2.tar.gz",
"has_sig": false,
"md5_digest": "b1300ddfae18a7604aa039c1510bb82d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21387,
"upload_time": "2016-12-27T06:19:48",
"upload_time_iso_8601": "2016-12-27T06:19:48.925982Z",
"url": "https://files.pythonhosted.org/packages/43/e7/6289123edb86eef09d43ece0648c2eb71d860f020ae17b2c7a52ffa8bbe9/CJKwrap-2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2016-12-27 06:19:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cjkwrap"
}