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.
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))
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.0.tar.gz
(2.7 kB
view details)
Built Distribution
File details
Details for the file cjkjust-0.1.0.tar.gz
.
File metadata
- Download URL: cjkjust-0.1.0.tar.gz
- Upload date:
- Size: 2.7 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 | 787df5ed6c97e4b531136473f3d2f791c04d233436fc62513d7e1271d604d6b7 |
|
MD5 | ddd2577a3742dc03da240102943d4fad |
|
BLAKE2b-256 | 6bbcec4d6a4bd99a5e874d25a8396ed10864edba63459700ef6c70e9cce4dc13 |
File details
Details for the file cjkjust-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: cjkjust-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.1 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 | 3736cdb94d6f80d8bf4ede6cfaec09f1dbd41cf97f2352c16e4a921597687c31 |
|
MD5 | e67305a737109951500f29a9ba637dae |
|
BLAKE2b-256 | 4d3f362238716ec6dc3f74c20465262081daadc0f856dafac87358e35520b491 |