• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

CJKwrap.egg-info/H03-May-2022-2726

licenses/H27-Dec-2016-1,097889

MANIFEST.inH A D27-Dec-201615 21

PKG-INFOH A D27-Dec-20161.1 KiB2726

README.rstH A D27-Dec-20162.1 KiB8460

cjkwrap.pyH A D27-Dec-20165 KiB149118

setup.cfgH A D27-Dec-201688 96

setup.pyH A D27-Dec-20161.2 KiB3129

README.rst

1CJKwrap
2=======
3
4**CJKwrap** is a library for wrapping and filling CJK text.
5
6CJKwrap fix the issue24665 because Python 2 will stay broken forever:
7https://bugs.python.org/issue24665.
8
9CJKwrap support **both** Python 2 (2.6 and above) and Python 3 (3.3 and above).
10
11CJKwrap is developed by Florent Gallaire fgallaire@gmail.com.
12
13Website: http://fgallaire.github.io/cjkwrap.
14
15Download and Install
16--------------------
17
18To install the last stable version from PyPI::
19
20    $ sudo pip install cjkwrap
21
22To install the development version from GitHub::
23
24    $ git clone https://github.com/fgallaire/cjkwrap
25    $ cd cjkwrap
26    $ sudo python setup.py install
27
28Or you can just use the ``cjkwrap.py`` file alone, nothing more needed!
29
30Usage
31-----
32
33``is_wide()`` to know if a char is double-width, ``cjklen()`` and ``cjkslices()`` to replace built-in ``len()`` and slicing::
34
35    >>> import cjkwrap
36    >>> cjkwrap.is_wide(u"c")
37    False
38    >>> cjkwrap.is_wide(u"長")
39    True
40    >>> cjkwrap.cjklen(u"最終的には良い長さ")
41    18
42    >>> head, tail = cjkwrap.cjkslices(u"最終的には良い長さ", 6)
43    >>> print(head)
44    最終的
45    >>> print(tail)
46    には良い長さ
47
48As ``cjklen()`` uses ``len()`` for non unicode stuff, you can safely do this::
49
50    >>> from cjkwrap import cjklen as len
51    >>> len(u"最終的には良い長さ")
52    18
53    >>> len([1, 2, 3, 4])
54    4
55
56``wrap()`` and ``fill()`` to replace the ones from the Python standard library::
57
58    >>> wrapped_cjk = cjkwrap.wrap(u"最終的に良いラッピング", 10)
59    >>> for line in wrapped_cjk: print(line)
60    ...
61    最終的に良
62    いラッピン
6364    >>> print(cjkwrap.fill(u"最終的に良いラッピング", 10))
65    最終的に良
66    いラッピン
6768
69Mixed content is allowed::
70
71    >>> cjkwrap.cjklen(u"CJK 最終的には良い長さ")
72    22
73    >>> print(cjkwrap.fill(u"CJK 最終的には良い長さ", 10))
74    CJK 最終的
75    には良い長
7677
78License
79-------
80
81CJKwrap files are released under the GNU LGPLv3 or above license.
82
83CJKwrap codebase from textwrap by Greg Ward (gward@python.net) under the Python license.
84