Skip to main content

Open Chinese Convert 開放中文轉換

CMake Bazel MSVC Node.js CI Python CI AppVeyor

Introduction 介紹

OpenCC

Open Chinese Convert (OpenCC, 開放中文轉換) is an opensource project for conversions between Traditional Chinese, Simplified Chinese and Japanese Kanji (Shinjitai). It supports character-level and phrase-level conversion, character variant conversion and regional idioms among Mainland China, Taiwan and Hong Kong. This is not translation tool between Mandarin and Cantonese, etc.

中文簡繁轉換開源項目,支持詞彙級別的轉換、異體字轉換和地區習慣用詞轉換(中國大陸、臺灣、香港、日本新字體)。不提供普通話與粵語的轉換。

Discussion (Telegram): https://t.me/open_chinese_convert

Features 特點

  • 嚴格區分「一簡對多繁」和「一簡對多異」。
  • 完全兼容異體字,可以實現動態替換。
  • 嚴格審校一簡對多繁詞條,原則爲「能分則不合」。
  • 支持中國大陸、臺灣、香港異體字和地區習慣用詞轉換,如「裏」「裡」、「鼠標」「滑鼠」。
  • 詞庫和函數庫完全分離,可以自由修改、導入、擴展。

Installation 安裝

See Download.

Usage 使用

Online demo 線上轉換展示

Warning: This is NOT an API. You will be banned if you make calls programmatically.

https://opencc.byvoid.com/

Node.js

npm npm install opencc

JavaScript

const OpenCC = require('opencc');
const converter = new OpenCC('s2t.json');
converter.convertPromise("汉字").then(converted => {
  console.log(converted);  // 漢字
});

TypeScript

import { OpenCC } from 'opencc';
async function main() {
  const converter: OpenCC = new OpenCC('s2t.json');
  const result: string = await converter.convertPromise('汉字');
  console.log(result);
}

See demo.js and ts-demo.ts.

Python

PyPI pip install opencc (Windows, Linux, Mac)

import opencc
converter = opencc.OpenCC('s2t.json')
converter.convert('汉字')  # 漢字

C++

#include "opencc.h"

int main() {
  const opencc::SimpleConverter converter("s2t.json");
  converter.Convert("汉字");  // 漢字
  return 0;
}

C

#include "opencc.h"

int main() {
  opencc_t opencc = opencc_open("s2t.json");
  const char* input = "汉字";
  char* converted = opencc_convert_utf8(opencc, input, strlen(input));  // 漢字
  opencc_convert_utf8_free(converted);
  opencc_close(opencc);
  return 0;
}

Document 文檔: https://byvoid.github.io/OpenCC/

Command Line

  • opencc --help
  • opencc_dict --help
  • opencc_phrase_extract --help

Others (Unofficial)

Configurations 配置文件

預設配置文件

  • s2t.json Simplified Chinese to Traditional Chinese 簡體到繁體
  • t2s.json Traditional Chinese to Simplified Chinese 繁體到簡體
  • s2tw.json Simplified Chinese to Traditional Chinese (Taiwan Standard) 簡體到臺灣正體
  • tw2s.json Traditional Chinese (Taiwan Standard) to Simplified Chinese 臺灣正體到簡體
  • s2hk.json Simplified Chinese to Traditional Chinese (Hong Kong variant) 簡體到香港繁體
  • hk2s.json Traditional Chinese (Hong Kong variant) to Simplified Chinese 香港繁體到簡體
  • s2twp.json Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
  • tw2sp.json Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙
  • t2tw.json Traditional Chinese (OpenCC Standard) to Taiwan Standard 繁體(OpenCC 標準)到臺灣正體
  • hk2t.json Traditional Chinese (Hong Kong variant) to Traditional Chinese 香港繁體到繁體(OpenCC 標準)
  • t2hk.json Traditional Chinese (OpenCC Standard) to Hong Kong variant 繁體(OpenCC 標準)到香港繁體
  • t2jp.json Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai) 繁體(OpenCC 標準,舊字體)到日文新字體
  • jp2t.json New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日文新字體到繁體(OpenCC 標準,舊字體)
  • tw2t.json Traditional Chinese (Taiwan standard) to Traditional Chinese 臺灣正體到繁體(OpenCC 標準)

Build 編譯

Build with CMake

Linux & Mac OS X

g++ 4.6+ or clang 3.2+ is required.

make

Windows Visual Studio:

build.cmd

Build with Bazel

bazel build //:opencc
bazel test --test_output=all //src/... //data/... //test/...

Test 測試

Linux & Mac OS X

make test

Windows Visual Studio:

test.cmd

Benchmark 基準測試

make benchmark

Example results (from Github CI):

1: ------------------------------------------------------------------
1: Benchmark                        Time             CPU   Iterations
1: ------------------------------------------------------------------
1: BM_Initialization/hk2s        1.56 ms         1.56 ms          442
1: BM_Initialization/hk2t       0.144 ms        0.144 ms         4878
1: BM_Initialization/jp2t       0.260 ms        0.260 ms         2604
1: BM_Initialization/s2hk        23.8 ms         23.8 ms           29
1: BM_Initialization/s2t         25.6 ms         25.6 ms           28
1: BM_Initialization/s2tw        24.0 ms         23.9 ms           30
1: BM_Initialization/s2twp       24.6 ms         24.6 ms           28
1: BM_Initialization/t2hk       0.052 ms        0.052 ms        12897
1: BM_Initialization/t2jp       0.141 ms        0.141 ms         5012
1: BM_Initialization/t2s         1.30 ms         1.30 ms          540
1: BM_Initialization/tw2s        1.39 ms         1.39 ms          529
1: BM_Initialization/tw2sp       1.69 ms         1.69 ms          426
1: BM_Initialization/tw2t       0.089 ms        0.089 ms         7707
1: BM_Convert2M                   582 ms          582 ms            1
1: BM_Convert/100                1.07 ms         1.07 ms          636
1: BM_Convert/1000               11.0 ms         11.0 ms           67
1: BM_Convert/10000               113 ms          113 ms            6
1: BM_Convert/100000             1176 ms         1176 ms            1

Projects using OpenCC 使用 OpenCC 的項目

Please update if your project is using OpenCC.

License 許可協議

Apache License 2.0

Third Party Library 第三方庫

All these libraries are statically linked by default.

Change History 版本歷史

Contributors 貢獻者

Please feel free to update this list if you have contributed OpenCC.

Metadata

Release files for OpenCC 1.1.8

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

Source distribution (sdist)

Source distribution for OpenCC 1.1.8
File Size Uploaded Provenance Actions
opencc-1.1.8.tar.gz 3.4 MB Without provenance Details for opencc-1.1.8.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for OpenCC 1.1.8
File Actions
OpenCC-1.1.8-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for OpenCC-1.1.8-cp312-cp312-win_amd64.whl
OpenCC-1.1.8-cp312-cp312-manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for OpenCC-1.1.8-cp312-cp312-manylinux2014_x86_64.whl
OpenCC-1.1.8-cp312-cp312-macosx_10_9_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.9+ x86-64 Details for OpenCC-1.1.8-cp312-cp312-macosx_10_9_x86_64.whl
OpenCC-1.1.8-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for OpenCC-1.1.8-cp311-cp311-win_amd64.whl
OpenCC-1.1.8-cp311-cp311-manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for OpenCC-1.1.8-cp311-cp311-manylinux2014_x86_64.whl
OpenCC-1.1.8-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details for OpenCC-1.1.8-cp311-cp311-macosx_10_9_x86_64.whl
OpenCC-1.1.8-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for OpenCC-1.1.8-cp310-cp310-win_amd64.whl
OpenCC-1.1.8-cp310-cp310-manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for OpenCC-1.1.8-cp310-cp310-manylinux2014_x86_64.whl
OpenCC-1.1.8-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details for OpenCC-1.1.8-cp310-cp310-macosx_10_9_x86_64.whl
OpenCC-1.1.8-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for OpenCC-1.1.8-cp39-cp39-win_amd64.whl
OpenCC-1.1.8-cp39-cp39-manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for OpenCC-1.1.8-cp39-cp39-manylinux2014_x86_64.whl
OpenCC-1.1.8-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details for OpenCC-1.1.8-cp39-cp39-macosx_10_9_x86_64.whl
OpenCC-1.1.8-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for OpenCC-1.1.8-cp38-cp38-win_amd64.whl
OpenCC-1.1.8-cp38-cp38-manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for OpenCC-1.1.8-cp38-cp38-manylinux2014_x86_64.whl
OpenCC-1.1.8-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details for OpenCC-1.1.8-cp38-cp38-macosx_10_9_x86_64.whl

Total release size: 27.9 MB

Release files / opencc-1.1.8.tar.gz

Download URL opencc-1.1.8.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
d380b1b6de580f6b72325d16b48ca3a1b9b2715640ebe3ea760910bcf5c78739
BLAKE2b-256 checksum
How to use checksums
77adf657b3e0be50fb4a0f6955f2dda9cb0f7346d9f8589aa38316d207c3e35f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp312-cp312-win_amd64.whl

Download URL OpenCC-1.1.8-cp312-cp312-win_amd64.whl
Size 1.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
19158433294a5c2e9f24f9461976f40240f04c54ed309a1f9d47c8e628bd9748
BLAKE2b-256 checksum
How to use checksums
6a3a36e8d94d9047c834718a8ea91d09499d8ef1a64f8e8a5557a75d490c4e99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / OpenCC-1.1.8-cp312-cp312-manylinux2014_x86_64.whl

Download URL OpenCC-1.1.8-cp312-cp312-manylinux2014_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6e620953210068e3ba1c2fb9d40320d9666e853c39ddf97cc9fc72e1cc8f3008
BLAKE2b-256 checksum
How to use checksums
28303756f37f804602c1ebce29b7260b88ffca57603fa6ea68d85c3b0257026e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp312-cp312-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.8-cp312-cp312-macosx_10_9_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
9b7d7909064b8eb05a1a7a62d496dff413e6456786cd4dfcd05ed55f3d89fe97
BLAKE2b-256 checksum
How to use checksums
7bf25ece9c1356ed0ddda9bdab9ddf8cbdeb889f8c05ee606967e7e004593a99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp311-cp311-win_amd64.whl

Download URL OpenCC-1.1.8-cp311-cp311-win_amd64.whl
Size 1.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7fd8a60c826df1ffec24d59329abfd3c48f3e1ba7a3ce90a16ff434b34bbda10
BLAKE2b-256 checksum
How to use checksums
f4f862a5bb8a515c5fc65ff29f40b0e20676da6f16b96b4c4faf077258cb96c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / OpenCC-1.1.8-cp311-cp311-manylinux2014_x86_64.whl

Download URL OpenCC-1.1.8-cp311-cp311-manylinux2014_x86_64.whl
Size 1.7 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2132e02726b981786955e9c8b23d96e440e7c782e7e25c40f8df8a88b3b48810
BLAKE2b-256 checksum
How to use checksums
cb4d7ced928d1dfa197a493ee9dd9d9c51883695d8701038b6c5b71a2f4e5826
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp311-cp311-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.8-cp311-cp311-macosx_10_9_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
1b1166f6a73faf21ecf0e2919fc1685ca2853c01f12360cee67154c658ce050f
BLAKE2b-256 checksum
How to use checksums
65447a217365bca3476fc8090866e5db96662a820c49f89c41aecc307bddc467
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp310-cp310-win_amd64.whl

Download URL OpenCC-1.1.8-cp310-cp310-win_amd64.whl
Size 1.8 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
78fe5982d88170940fb5d4960c58a4d8519eb1d5bef3788bee9aeb9147b03048
BLAKE2b-256 checksum
How to use checksums
39b14de1d42bb23bec0e999a5accef62acde93cf582d59666454a1c764702f3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / OpenCC-1.1.8-cp310-cp310-manylinux2014_x86_64.whl

Download URL OpenCC-1.1.8-cp310-cp310-manylinux2014_x86_64.whl
Size 1.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
76edd60b09bfe0acc546b49a5687fe71487771aee28b45fa22f993602d8400ff
BLAKE2b-256 checksum
How to use checksums
83722cf565957cf4915a90899dad666928d02ba8160d92da48962210ba0c7d4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp310-cp310-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.8-cp310-cp310-macosx_10_9_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
9b968fcaa55f7a0afd44cd22240a90bf33e4cf26591250bf87b8c148fd3f564b
BLAKE2b-256 checksum
How to use checksums
810214e702295ac3f5d7443d18d57d384fc4c33ef2e17002ae925cf9317b90bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp39-cp39-win_amd64.whl

Download URL OpenCC-1.1.8-cp39-cp39-win_amd64.whl
Size 1.8 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
3fa7a4f326409c68883542111941d603d8c8c09ee746cc3c92579a55c5d65c50
BLAKE2b-256 checksum
How to use checksums
47fc66d55be61f1c36bb4116cc24bbb8377491af5d457b60abd31cfb364556d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / OpenCC-1.1.8-cp39-cp39-manylinux2014_x86_64.whl

Download URL OpenCC-1.1.8-cp39-cp39-manylinux2014_x86_64.whl
Size 1.7 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d60c4f3d0de8ef488b4b51767e4d7841dd0677847f33dd666e81b4b318214c19
BLAKE2b-256 checksum
How to use checksums
88505bcf9d77982834f5ed4af6d0173a1edd675fd567527d0edac7ba33e6231f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp39-cp39-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.8-cp39-cp39-macosx_10_9_x86_64.whl
Size 1.5 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
9d1ee4abf4042f4a894723a9dac29f3ea6ff611c5afc4f945cbbcc7cf4a4ba18
BLAKE2b-256 checksum
How to use checksums
3f7da2acf2898788bcf89bc08cd5e04b1b3ca362de094514d0319df23fbdd5bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp38-cp38-win_amd64.whl

Download URL OpenCC-1.1.8-cp38-cp38-win_amd64.whl
Size 1.8 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
97826f62fe1ab03b18bce1390f296d07592f5b2e9345dfd1f2699998ad8b8bf0
BLAKE2b-256 checksum
How to use checksums
b29acd745751b7ce1178cd1e15cd077698e4d177f2205f1d83d72d1979ddd208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release files / OpenCC-1.1.8-cp38-cp38-manylinux2014_x86_64.whl

Download URL OpenCC-1.1.8-cp38-cp38-manylinux2014_x86_64.whl
Size 1.7 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
de1553ad0146b19908c01c44d65e9134cb31f0b98deed6355324408346b22286
BLAKE2b-256 checksum
How to use checksums
dca9cbf0c9bc95c8e17ee6b735d34a9b14978acf891ef89735c56e7cb94e924c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / OpenCC-1.1.8-cp38-cp38-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.8-cp38-cp38-macosx_10_9_x86_64.whl
Size 1.5 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
7c46e1f2cb8e74eadb1eac2034c84d937272e0f7e50c8efbaee14b51d61ddea4
BLAKE2b-256 checksum
How to use checksums
cf7162915ca7f520a5a2fcd3d18272cffb114ab2f3407f554300504e1dd2d8f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Security for OpenCC 1.1.8

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.

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