8 releases
new 0.3.1 | Feb 21, 2025 |
---|---|
0.3.0 | Feb 20, 2025 |
0.2.5 | Feb 20, 2025 |
#510 in Text processing
384 downloads per month
475KB
580 lines
Hanconv
Hanconv converts between Chinese characters variants base 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 other projects.
Installation
cargo install hanconv
Usage
Command-Line Interface
-
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
-
Specify input and output encoding:
hanconv t2s -i input.txt -o output.txt --encoding GBK
As a Library
-
Add
hanconv
as a dependency in yourCargo.toml
.[dependencies] hanconv = "0.2"
-
Use the provided conversion functions in your project.
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) |
Dependencies
~6MB
~162K SLoC