Skip to main content

Hanconv

Convert between Chinese character variants.

Hanconv crate version and downloads on crates.io

English ┃ 简体中文

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

  1. Add hanconv as a dependency in your Cargo.toml.

    [dependencies]
    hanconv = "0.6"
    
  2. Use the provided conversion functions in your project.

    fn main() {
        let result = hanconv::s2t("简繁转换");
        assert_eq!(result, "簡繁轉換");
    }
    
  3. Available conversion functions:

    • 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)

Go Package

  1. Add hanconv to your Go project:

    go get github.com/fhluo/hanconv/go
    
  2. 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

  1. Install the package with pip:

    pip install hanconv
    

    Or with uv:

    uv add hanconv
    
  2. 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-cli 0.6.0

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

Source distribution (sdist)

Source distribution for hanconv-cli 0.6.0
File Size Uploaded Provenance Actions
hanconv_cli-0.6.0.tar.gz 563.0 kB Without provenance Details for hanconv_cli-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for hanconv-cli 0.6.0
File Actions
hanconv_cli-0.6.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for hanconv_cli-0.6.0-py3-none-win_arm64.whl
hanconv_cli-0.6.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for hanconv_cli-0.6.0-py3-none-win_amd64.whl
hanconv_cli-0.6.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for hanconv_cli-0.6.0-py3-none-manylinux_2_28_x86_64.whl
hanconv_cli-0.6.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for hanconv_cli-0.6.0-py3-none-manylinux_2_28_aarch64.whl
hanconv_cli-0.6.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for hanconv_cli-0.6.0-py3-none-macosx_11_0_arm64.whl

Total release size: 6.2 MB

Release files / hanconv_cli-0.6.0.tar.gz

Download URL hanconv_cli-0.6.0.tar.gz
Size 563.0 kB
Tags Source
SHA-256 checksum
How to use checksums
617d4d76e0e898e7399af9f3cf3071b9e3def10e86ca4e6e3b1df1eee7b52ebe
BLAKE2b-256 checksum
How to use checksums
9a8c6876dfdb5c7eee32336cda595268b8207c825ad50234495358c51ce7193e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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_cli-0.6.0-py3-none-win_arm64.whl

Download URL hanconv_cli-0.6.0-py3-none-win_arm64.whl
Size 1.0 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
ac24e8a87fe05fe49df7a4dbba31cc2eb1ae9b2bb67aa7d85d68a3000f7eb78b
BLAKE2b-256 checksum
How to use checksums
77535ccc4c75c5ca363c24a1012f5bea4cb02c7fd1af1948d8da8803ccff3d4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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_cli-0.6.0-py3-none-win_amd64.whl

Download URL hanconv_cli-0.6.0-py3-none-win_amd64.whl
Size 1.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
e01a8c9dab834fbd5be37a02759f12f6ae479be63efa7233fd53a2273d8179a9
BLAKE2b-256 checksum
How to use checksums
31b3af4c3cf7f255c045d4b9f280517af62437bfa22a32bba23aa533d4a42eb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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_cli-0.6.0-py3-none-manylinux_2_28_x86_64.whl

Download URL hanconv_cli-0.6.0-py3-none-manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f5173d9fd7f31984d5d1679a163e74cf441c0a56491d47036a7d4100f1c46075
BLAKE2b-256 checksum
How to use checksums
13ffaa2f5ee5865db529c858d202f6978ef9c0b597363c5ce483c39cc3a4fa4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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_cli-0.6.0-py3-none-manylinux_2_28_aarch64.whl

Download URL hanconv_cli-0.6.0-py3-none-manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
962b93263b1d43b0d6c2a19fb3f0722a900fb04d0da6395daffe10a507cbfb57
BLAKE2b-256 checksum
How to use checksums
6962f4042036f9788b338c558bea07158f954b61196979f5eb163d093b307451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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_cli-0.6.0-py3-none-macosx_11_0_arm64.whl

Download URL hanconv_cli-0.6.0-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1f87aefdd36e006f4e9cf9a07dd81934fe7b9c7bc28879767bc013d9ed077109
BLAKE2b-256 checksum
How to use checksums
efbeea198a2788cc8372be05345f0ca87adc986ee3b0f1f3b032137b96b9e621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","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-cli 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.

Release history Release notifications | RSS feed

This release

0.6.0 This release

6 release files No provenance

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