Having strings containing CJK characters left-, right-justified or centered conveniently.
Project description
cjkjust
Having strings containing CJK characters left-, right-justified or centered conveniently.
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
and explicitly setcjkjust.raises_on_indeterminate
toTrue
implies thatValueError
will be raised if indeterminate-width-characters (e.g.<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.4.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file cjkjust-0.1.4.tar.gz
.
File metadata
- Download URL: cjkjust-0.1.4.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83d981b19118619bd52424291e8ccf7fcb89a4b6f116d7b0bdf614b8da76eba7 |
|
MD5 | 9372c20c1cb82e264fbef4bb36a5df4f |
|
BLAKE2b-256 | 710832873be28e3ae14259a498b92d877f64d85b5be79409c1c204f1b460483b |
File details
Details for the file cjkjust-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: cjkjust-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39a1d85b09b6f73c78e9e83fd2d587fb0c905bcc9e8e4ec235d64b695bf9da73 |
|
MD5 | 31921f85d104bdafea39c3922621bc36 |
|
BLAKE2b-256 | 6328b9f8bd9d420f22b5cd7fc66ddd9ec581399d6a597ea6738d4d0217832cd5 |