Having strings containing CJK characters left-, right-justified or centered gracefully.
Project description
cjkjust
Having strings containing CJK characters left-, right-justified or centered gracefully.
Installation
pip install cjkjust
Functions
is_wide(char) -> bool
: returns whether a characterchar
is widecjklen(string) -> int
: returns the display width of astring
containing CJK characterscjkljust(string, width: int, fillbyte=' ')
: hasstring
left-justifiedcjkrjust(string, width: int, fillbyte=' ')
: hasstring
right-justifiedcjkcenter(string, width: int, fillbyte=' ')
: hasstring
centered
Caveat: <TAB>
in string
ruins the print-out.
Examples
import cjkjust
# right-justify a column of strings
print(cjkjust.cjkrjust('hello 世界', 20))
print(cjkjust.cjkrjust('你好world', 20))
print(cjkjust.cjkrjust('again and again', 20))
Optional dependency
wcwidth
: if installed, 0-width characters will also be well handled incjkljust
,cjkrjust
, andcjkcenter
. Caveat: installingwcwidth
implies thatValueError
will be raised if<TAB>
is instring
It can be installed along with cjkjust
by:
pip install cjkjust[allchars]
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
cjkjust-0.1.2.1.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file cjkjust-0.1.2.1.tar.gz
.
File metadata
- Download URL: cjkjust-0.1.2.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a52d8075380e31817035941623222ce60812e383920e69d6401780e4d7a3255 |
|
MD5 | fb3080085e621520f12a83775b6ed005 |
|
BLAKE2b-256 | 9e4018e8f0920d4bae83584ba0888471b6fd51199721dda2f62d647d7bef7adc |
File details
Details for the file cjkjust-0.1.2.1-py3-none-any.whl
.
File metadata
- Download URL: cjkjust-0.1.2.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc0138acdfd0b069dd0bea1fe62d7de6d2df5f4d06fac131c9b05ac622954f45 |
|
MD5 | 248555234483d9ccea1a6b5b11f615ec |
|
BLAKE2b-256 | 9897fb89883ee820309b4d7321acd56b0e9185f728a8f4ef169eecfa077eae51 |