Skip to main content

CJKStr -- A Simple Package for Processing CJK string

In Python, the string formatting function will treat a CJK characters as wide as a english letter.This make the result weired. For example:

print("1234567890" * 4) 
a = "測試"
w = 10
print(f"{a:{w}s}|")

produce output as this:

1234567890123456789012345678901234567890
測試        |

The width is setting to 10 in the formatting string. Since the 2 Chinese characters occupies 2 more spaces, the bar is printed in position 13.

To avoid this problem, we need to know how many CJK Chinese characters in the string and resuce the width accorantly.

This package has only one funcion:

count_cjk_chars(s) # return number of chinese characters in string s

example

import cjkstr

print("1234567890" * 4) 
a = "測試"
w = 10
print(f"{a:{w}s}|")
w = 10 - cjkstr.count_cjk_chars(a)
print(f"{a:{w}s}|")

ouput:

1234567890123456789012345678901234567890
測試        |
測試      |

Metadata

Release files for cjkstr 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cjkstr 0.0.5
File Size Uploaded Provenance Actions
cjkstr-0.0.5.tar.gz 1.8 kB Without provenance Details for cjkstr-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cjkstr 0.0.5
File Interpreter ABI Platform Actions
cjkstr-0.0.5-py3-none-any.whl Python 3 none any Details for cjkstr-0.0.5-py3-none-any.whl

Total release size: 4.6 kB

Release files / cjkstr-0.0.5.tar.gz

Download URL cjkstr-0.0.5.tar.gz
Size 1.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a47d8d40e4458dacd7d93994862a3295d1edb20b75d841f01b1e186bcd46ba0e
BLAKE2b-256 checksum
How to use checksums
9e5d18f672ffefbf92a80b69cde9dca1b00e4b7789adc2b023c182ca4250f3f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

Release files / cjkstr-0.0.5-py3-none-any.whl

Download URL cjkstr-0.0.5-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76617d7ea9b721bf2fa392e6bbede2ad285eae256da6aeee0525511222a8b629
BLAKE2b-256 checksum
How to use checksums
649cc6945c6b7a44708577b63e280e7629ccf295a9ee232aef7fefe05ffe03e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

Security for cjkstr 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page