Skip to main content

This Python 3 module provides utility functions for formatting fixed-width CJK strings.

Project description

CJK Format

This Python 3 module provides utility functions for formatting fixed-width CJK strings. One of the most important features of tihs module is to align Latin and CJK characters using %{width}s specifiers. For example, the following lines

print('%-10s|%-10s|' % ('ab', 'cd'))
print('%-10s|%-10s|' % ('가나다라', '마바사아'))

will print misaligned lines between Latin and CJK characters even with the %-10s specifiers.

Now, using this module's f() function, the above example would be

from cjkformat import f

print(f('%-10s|%-10s|', 'ab', 'cd'))
print(f('%-10s|%-10s|', '가나다라', '마바사아'))

which will print nicely aligned output.

The module also defines a shortcut function printf() to minic the same function in the C language. For example,

from cjkformat import printf

printf('%-10s|%-10s|\n', 'ab', 'cd')
printf('%-10s|%-10s|\n', '가나다라', '마바사아')

For more information, please visit the GitHub repository.

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

cjkformat-0.1.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

cjkformat-0.1.1-py3-none-any.whl (15.6 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