Skip to main content

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 character char is wide
  • cjklen(string) -> int: returns the display width of a string containing CJK characters
  • cjkljust(string, width: int, fillbyte=' '): has string left-justified
  • cjkrjust(string, width: int, fillbyte=' '): has string right-justified
  • cjkcenter(string, width: int, fillbyte=' '): has string 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 in cjkljust, cjkrjust, and cjkcenter. Caveat: installing wcwidth and explicitly set cjkjust.raises_on_indeterminate to True implies that ValueError will be raised if indeterminate-width-characters (e.g. <TAB>) is in string

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)

Uploaded Source

Built Distribution

cjkjust-0.1.4-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for cjkjust-0.1.4.tar.gz
Algorithm Hash digest
SHA256 83d981b19118619bd52424291e8ccf7fcb89a4b6f116d7b0bdf614b8da76eba7
MD5 9372c20c1cb82e264fbef4bb36a5df4f
BLAKE2b-256 710832873be28e3ae14259a498b92d877f64d85b5be79409c1c204f1b460483b

See more details on using hashes here.

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

Hashes for cjkjust-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 39a1d85b09b6f73c78e9e83fd2d587fb0c905bcc9e8e4ec235d64b695bf9da73
MD5 31921f85d104bdafea39c3922621bc36
BLAKE2b-256 6328b9f8bd9d420f22b5cd7fc66ddd9ec581399d6a597ea6738d4d0217832cd5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page