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.3.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file cjkjust-0.1.3.tar.gz
.
File metadata
- Download URL: cjkjust-0.1.3.tar.gz
- Upload date:
- Size: 3.1 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 | 1f9bacbf9141cb1891adc102f0fd128b5a432fc079eb5aebbde86e14ec08c186 |
|
MD5 | 68c24fac32c0fae2b2dad817adab0c42 |
|
BLAKE2b-256 | 3ae5f58e9696b7b51218a8f2471fd3395970c9b4c4d6c25b496fee201461c6d7 |
File details
Details for the file cjkjust-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: cjkjust-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.3 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 | cc71dd3d1a9b4608e50c3389e78d62d25bdaddde73fb55f86e8a8e1d756ef826 |
|
MD5 | 3525e159fec9162119e606c3b2504009 |
|
BLAKE2b-256 | 81bdd97b59d8710c2d04fd4f31ec7afc9481fae0ade8b95adfcf99ccfbd5b1e9 |