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.

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

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

Uploaded Source

Built Distribution

cjkjust-0.1.0-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

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