Skip to main content
https://img.shields.io/pypi/v/chinese-to-english-punctuation.svg https://img.shields.io/pypi/l/chinese-to-english-punctuation.svg https://img.shields.io/pypi/pyversions/chinese-to-english-punctuation.svg https://img.shields.io/badge/✍️_Release_History!--None.svg?style=social&logo=github https://img.shields.io/badge/⭐_Star_me_on_GitHub!--None.svg?style=social&logo=github
https://img.shields.io/badge/Link-Install-blue.svg https://img.shields.io/badge/Link-GitHub-blue.svg https://img.shields.io/badge/Link-Submit_Issue-blue.svg https://img.shields.io/badge/Link-Request_Feature-blue.svg https://img.shields.io/badge/Link-Download-blue.svg

Welcome to chinese_to_english_punctuation Documentation

chinese_to_english_punctuation rewrites Chinese full-width punctuation into its English half-width equivalent, and fixes the spacing around it. Documents written by Chinese speakers about technical topics almost always end up mixing the two: the narrative uses ,。:;?!()“” while the technical terms stay in English. That mix reads poorly in Markdown and reStructuredText, and it breaks tooling that expects ASCII punctuation. This library converts to ,, to ., () to () and so on, inserts the single space that belongs between a Chinese character and an adjacent Latin word or number, and leaves everything else alone.

The conversion is line-oriented and deliberately conservative about structure. Leading indentation is preserved verbatim, so fenced code blocks, .. code-block directives and nested list continuations survive untouched. Runs of two or three identical marks (。。。, ???, !!!) are treated as a single unit rather than being split apart. Spaces that would otherwise be introduced just inside paired Markdown markers such as **bold** are cleaned up afterwards.

The public Python API is a single function, process, which takes text and returns text. The same behavior is available from the command line through c2ep, which offers c2ep text for reading from --text or stdin and writing to stdout, and c2ep file for rewriting a UTF-8 file in place. Files that are not valid UTF-8 are rejected rather than guessed at, and --dry_run reports what would change without touching anything.

Usage:

from chinese_to_english_punctuation.api import process

process("这是Python代码,它使用Flask框架。")
# '这是 Python 代码, 它使用 Flask 框架.'
$ c2ep text --text "这是Python代码,它使用Flask框架。"
这是 Python 代码, 它使用 Flask 框架.

$ c2ep file --path ./README.md --dry_run
./README.md: 12 line(s) would change (dry run, nothing written)

$ c2ep file --path ./README.md
./README.md: 12 line(s) changed

Install

chinese_to_english_punctuation is released on PyPI, so all you need is to:

$ pip install chinese-to-english-punctuation

To upgrade to latest version:

$ pip install --upgrade chinese-to-english-punctuation

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chinese_to_english_punctuation-0.1.1.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chinese_to_english_punctuation-0.1.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chinese_to_english_punctuation-0.1.1.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chinese_to_english_punctuation-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3db014ca1fca057c8adcc79010697989910f240bcf364daf75fbb8b06e483fab
MD5 f5318bd69e4910c4528b32d8db35125b
BLAKE2b-256 63c08c8d14f926ce609661d0ef241d650d4659452d103a4c55c173e0675b514d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chinese_to_english_punctuation-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chinese_to_english_punctuation-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0214f2cc2a99d5d078d17ca8d71a1be9a74e8b47ffa25e5fe6c7feb070820d8
MD5 e6a0a361ebd0c8c1013fe0431d13b74e
BLAKE2b-256 6538a7bf3dbdfd6c79edd26115fc487137c9fad5a0f464cabbe17993826aed06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page