Hanconv converts between Chinese character variants based on OpenCC's dictionaries and conversion rules. It provides efficient conversion between Simplified Chinese and Traditional Chinese both as a command-line tool and as a library for integration into Rust, Go, and Python projects.
Table of Contents
Command-Line Tool
Install the command-line tool with Cargo:
cargo install hanconv-cli
Or install it with Go:
go install github.com/fhluo/hanconv/go/cmd/hanconv@latest
Basic usage:
-
Display the help message:
hanconv --help -
Convert a text file from Simplified to Traditional Chinese:
hanconv s2t -i input.txt -o output.txt
-
Convert a text file from Traditional to Simplified Chinese:
hanconv t2s -i input.txt -o output.txt
-
Convert text directly from the command line:
hanconv s2t "简繁转换"
-
Read from stdin and write to stdout:
cat input.txt | hanconv s2t > output.txt
-
For files with non-UTF-8 encodings, specify the encoding:
# Same encoding for input and output hanconv t2s -i input.txt -o output.txt --encoding GBK # Different encodings for input and output hanconv t2s -i input.txt -o output.txt --input-encoding GBK --output-encoding UTF-8
Rust Library
-
Add
hanconvas a dependency in yourCargo.toml.[dependencies] hanconv = "0.6"
-
Use the provided conversion functions in your project.
fn main() { let result = hanconv::s2t("简繁转换"); assert_eq!(result, "簡繁轉換"); }
-
Available conversion functions:
s2t: Simplified Chinese → Traditional Chineset2s: Traditional Chinese → Simplified Chineses2tw: Simplified Chinese → Traditional Chinese (Taiwan)tw2s: Traditional Chinese (Taiwan) → Simplified Chineses2twp: Simplified Chinese → Traditional Chinese (Taiwan) with Taiwanese idiomtw2sp: Traditional Chinese (Taiwan) → Simplified Chinese with Mainland Chinese idiomt2tw: Traditional Chinese → Traditional Chinese (Taiwan)tw2t: Traditional Chinese (Taiwan) → Traditional Chineses2hk: Simplified Chinese → Traditional Chinese (Hong Kong)hk2s: Traditional Chinese (Hong Kong) → Simplified Chineset2hk: Traditional Chinese → Traditional Chinese (Hong Kong)hk2t: Traditional Chinese (Hong Kong) → Traditional Chineset2jp: Traditional Chinese characters (Kyūjitai) → New Japanese Kanji (Shinjitai)jp2t: New Japanese Kanji (Shinjitai) → Traditional Chinese characters (Kyūjitai)
Go Package
-
Add hanconv to your Go project:
go get github.com/fhluo/hanconv/go
-
Import and use the conversion functions in your project:
import hanconv "github.com/fhluo/hanconv/go" func main() { result := hanconv.S2T("简繁转换") fmt.Println(result) }
Python Package
-
Install the package with pip:
pip install hanconv
Or with uv:
uv add hanconv
-
Import and use the conversion functions in your project:
import hanconv result = hanconv.s2t("简繁转换") assert result == "簡繁轉換"
Conversions
| Conversion | Source | Target |
|---|---|---|
| S2T | Simplified Chinese | Traditional Chinese |
| T2S | Traditional Chinese | Simplified Chinese |
| S2TW | Simplified Chinese | Traditional Chinese (Taiwan) |
| TW2S | Traditional Chinese (Taiwan) | Simplified Chinese |
| S2TWP | Simplified Chinese | Traditional Chinese (Taiwan) with Taiwanese idiom |
| TW2SP | Traditional Chinese (Taiwan) | Simplified Chinese with Mainland Chinese idiom |
| T2TW | Traditional Chinese | Traditional Chinese (Taiwan) |
| TW2T | Traditional Chinese (Taiwan) | Traditional Chinese |
| S2HK | Simplified Chinese | Traditional Chinese (Hong Kong) |
| HK2S | Traditional Chinese (Hong Kong) | Simplified Chinese |
| T2HK | Traditional Chinese | Traditional Chinese (Hong Kong) |
| HK2T | Traditional Chinese (Hong Kong) | Traditional Chinese |
| T2JP | Traditional Chinese characters (Kyūjitai) | New Japanese Kanji (Shinjitai) |
| JP2T | New Japanese Kanji (Shinjitai) | Traditional Chinese characters (Kyūjitai) |
Metadata
Release files for hanconv 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hanconv-0.6.0.tar.gz | 564.2 kB | Without provenance | Details for hanconv-0.6.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| hanconv-0.6.0-cp313-abi3-win_arm64.whl | CPython 3.13 | abi3 | Windows ARM64 | Details for hanconv-0.6.0-cp313-abi3-win_arm64.whl |
| hanconv-0.6.0-cp313-abi3-win_amd64.whl | CPython 3.13 | abi3 | Windows x86-64 | Details for hanconv-0.6.0-cp313-abi3-win_amd64.whl |
| hanconv-0.6.0-cp313-abi3-manylinux_2_28_x86_64.whl | CPython 3.13 | abi3 | Linux glibc 2.28+ x86-64 | Details for hanconv-0.6.0-cp313-abi3-manylinux_2_28_x86_64.whl |
| hanconv-0.6.0-cp313-abi3-manylinux_2_28_aarch64.whl | CPython 3.13 | abi3 | Linux glibc 2.28+ ARM64 | Details for hanconv-0.6.0-cp313-abi3-manylinux_2_28_aarch64.whl |
| hanconv-0.6.0-cp313-abi3-macosx_11_0_arm64.whl | CPython 3.13 | abi3 | macOS 11.0+ ARM64 | Details for hanconv-0.6.0-cp313-abi3-macosx_11_0_arm64.whl |
Total release size: 4.0 MB
Release files / hanconv-0.6.0.tar.gz
| Download URL | hanconv-0.6.0.tar.gz |
|---|---|
| Size | 564.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40308098815f42a9801b6a63ceb4e23a76c512429d4666e69076fb4f8caf10c3
|
|
BLAKE2b-256 checksum How to use checksums |
9007d54056fb30f72a0331ae1a91c37cf1c0fb018951eb86bc452ba9729a3183
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hanconv-0.6.0-cp313-abi3-win_arm64.whl
| Download URL | hanconv-0.6.0-cp313-abi3-win_arm64.whl |
|---|---|
| Size | 616.4 kB |
| Tags | CPython 3.13 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
831d42b608254b766c711215810a2d08faa33504493d3c8f302dfb520907a263
|
|
BLAKE2b-256 checksum How to use checksums |
2bcc2a3f9d157d451604994448100e2d3537e68e9a4443ca0e00144ff5576f08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hanconv-0.6.0-cp313-abi3-win_amd64.whl
| Download URL | hanconv-0.6.0-cp313-abi3-win_amd64.whl |
|---|---|
| Size | 618.2 kB |
| Tags | CPython 3.13 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6468071ade66cf759cc5568e0a6fde6c97b209a5a76b494008ab343ef0cfb6ab
|
|
BLAKE2b-256 checksum How to use checksums |
3fd528862c1e657ad9c7aff36f81785d4852b93c30a347ed216000668a02f2e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hanconv-0.6.0-cp313-abi3-manylinux_2_28_x86_64.whl
| Download URL | hanconv-0.6.0-cp313-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 747.7 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f4dcfb860da37458b8f60e2b1972e07ff5ca1e118bb816ea6cfa81772396e2e6
|
|
BLAKE2b-256 checksum How to use checksums |
03ee6f2e206fa8e654a5a77d661927e54bfa1af592f05daa933994816589882f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hanconv-0.6.0-cp313-abi3-manylinux_2_28_aarch64.whl
| Download URL | hanconv-0.6.0-cp313-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 740.3 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
75e100896a92ef607ff5636a14db03e992a3f7e925ee50475c1554c56cf02d4c
|
|
BLAKE2b-256 checksum How to use checksums |
44a8ece0b23e01eabbcdb7f2a70982a214c8810d7f82168542ec331f7bbdd1f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hanconv-0.6.0-cp313-abi3-macosx_11_0_arm64.whl
| Download URL | hanconv-0.6.0-cp313-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 721.8 kB |
| Tags | CPython 3.13 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3cebf95e596950dd7fb774ec9483fd499b31e814ddc8923fa0004a70a843cd14
|
|
BLAKE2b-256 checksum How to use checksums |
b0e6bbe989179c12a10fdfee69e3d51ea9ab02a9ef8643b71226db6735927e52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for hanconv 0.6.0
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.