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 [] to [], 《》 and 〈〉 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

Metadata

Release files for chinese_to_english_punctuation 0.1.2

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

Source distribution (sdist)

Source distribution for chinese_to_english_punctuation 0.1.2
File Size Uploaded
chinese_to_english_punctuation-0.1.2.tar.gz 22.8 kB Details

Built distribution (wheel)

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

Total release size: 39.9 kB

Release files / chinese_to_english_punctuation-0.1.2.tar.gz

Download URL chinese_to_english_punctuation-0.1.2.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
01d83c2f009d0d3fce0e8d4d2306cd9a0114f7c1caacf560e3ae9b93c05a29b4
BLAKE2b-256 checksum
How to use checksums
cf7fd863a864082563068d57b8b46374f89b95adab395f642f29b81fe6609c3d
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / chinese_to_english_punctuation-0.1.2-py3-none-any.whl

Download URL chinese_to_english_punctuation-0.1.2-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbf9421de4107c8d70fa288a9684cfa2d4657f53e73ac27baf50120919a30a89
BLAKE2b-256 checksum
How to use checksums
83c55971026fde77087d6e84ad319088dd99ad60d5350b04a1cd3bf26f71d52b
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

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