Skip to main content

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 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

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.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

cjkjust-0.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file cjkjust-0.1.1.tar.gz.

File metadata

  • Download URL: cjkjust-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 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

Hashes for cjkjust-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eb3e356b4d78241e5add2963cc8fd7bbc75369e3aeb5b2641ba3bcb1f9d7a588
MD5 f9b9afa302798375d9ff2f58d83be5db
BLAKE2b-256 7ea7f9b036dcee32e68f428ecd65708ba680f302d2315d82dccb3ba2f88fe831

See more details on using hashes here.

File details

Details for the file cjkjust-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cjkjust-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 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

Hashes for cjkjust-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f55d89dd62156ee5c1c0b5a9ceb3bb69b9950fc47e7f7d9dd44d861ee4e18d12
MD5 0098252cb7ebdc6d02f9836077dca652
BLAKE2b-256 139925e2a2ad7fdcb8a6385277eab0e4bc44151565d416e2cd9f35869a317fe3

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