Skip to main content

Open Chinese Convert 開放中文轉換

Travis AppVeyor C/C++ CI Node.js CI Python CI

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

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 的項目

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.7

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

Built distributions (wheels)

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

Total release size: 11.2 MB

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

Download URL OpenCC-1.1.7-cp312-cp312-win_amd64.whl
Size 716.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
7f3f843f0b47afa0bff91ea5b9fbf9968f19ffbaffda9508615993058246ca3c
BLAKE2b-256 checksum
How to use checksums
71661d56f4cf2c80243d3f8e715bfd81a2e4413691e9a8a2e07c827d7e2f6596
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / OpenCC-1.1.7-cp312-cp312-manylinux1_x86_64.whl

Download URL OpenCC-1.1.7-cp312-cp312-manylinux1_x86_64.whl
Size 779.7 kB
Tags CPython 3.12 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
dc5d6443b833e1a45bcad4d4312c680d9d574a365491357165d927a3eecac5f0
BLAKE2b-256 checksum
How to use checksums
925a7b1cd306d435434058ea4a97467f0f2e74408ed54be4b2ae3d40d337ab5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp312-cp312-macosx_10_9_x86_64.whl
Size 735.7 kB
Tags CPython 3.12 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
253e7d636ad0aad2e70e616d2185181e0104687f53ec38974f7b67221c475382
BLAKE2b-256 checksum
How to use checksums
688695196525a59c440d03b182e638f1cd0ad2b74e2e41e37c6f931b4bb85fd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp311-cp311-win_amd64.whl
Size 715.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d2d4705b3f599903784b4d4be6a557c591aeeb93d2b99b8f19d3e13dee4fab10
BLAKE2b-256 checksum
How to use checksums
f076a9a5cedb776401a5ac470fb92be910012410d6334693e4799b2544493de5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / OpenCC-1.1.7-cp311-cp311-manylinux1_x86_64.whl

Download URL OpenCC-1.1.7-cp311-cp311-manylinux1_x86_64.whl
Size 779.7 kB
Tags CPython 3.11 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
3ed6f128383375b9dc5c3db02ffa9d6ac1a14242656414bab85a18ef65daf645
BLAKE2b-256 checksum
How to use checksums
18a29ccfc1e1c49f6643b2bc090ba2a5bca5df6a2754e5049caa1909609bdccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp311-cp311-macosx_10_9_x86_64.whl
Size 734.8 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
8aa4b1203bf78ced40ae4da7206089ccd459f823a1b05f311b653eb08dce7d0d
BLAKE2b-256 checksum
How to use checksums
a2999bf06f2111f682ce8c1cf6b57a01b651b0c9d786e7d650b1f7cb6ac0d6a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp310-cp310-win_amd64.whl
Size 716.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
8fa764bbb93ff97f50d1f70ca2542c9108adb763845d690e256664a61c98f914
BLAKE2b-256 checksum
How to use checksums
0c89aaae6b007603e5021a3b7dc0f53835cad9065999f342a9ed4d7779dd0c9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / OpenCC-1.1.7-cp310-cp310-manylinux1_x86_64.whl

Download URL OpenCC-1.1.7-cp310-cp310-manylinux1_x86_64.whl
Size 779.8 kB
Tags CPython 3.10 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
fc4fb3ec08dcbdb430cbd70d14f9457f2b2ef2d51b08bf079b9cee0c6def3eed
BLAKE2b-256 checksum
How to use checksums
df273d4652dcf73d1ddde83348ab167dc33372822f96eac76fd6235d5144868a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp310-cp310-macosx_10_9_x86_64.whl
Size 734.8 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
ba77d5eb376129adcad090a07b0edbee293f26513f14a135a9cb17af004defd1
BLAKE2b-256 checksum
How to use checksums
0a28aed41e348d84cefbacd80e8715969c3acbbf0d849335ef924946655960d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp39-cp39-win_amd64.whl
Size 716.1 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
6455d2548e2211d28cfa68d25aceeb4ff06c6a396264dcefe5a2b885ffeaf783
BLAKE2b-256 checksum
How to use checksums
58e09adbd3983da5bf627a097dbfb81acfa02d68e6e97b8be367968b88dde6f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / OpenCC-1.1.7-cp39-cp39-manylinux1_x86_64.whl

Download URL OpenCC-1.1.7-cp39-cp39-manylinux1_x86_64.whl
Size 779.9 kB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b55ad5edf93a45e89519fa4aa80384d7021fd795fdf8c9315b6898fa2a0e202a
BLAKE2b-256 checksum
How to use checksums
1fef5221cf0909fcf44e33176a89af15728b581c45a6fe5f4201ea8a5640bcda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp39-cp39-macosx_10_9_x86_64.whl
Size 734.9 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
a16b7ed7d01b77b133a51e41903c5c83486de5be5483164c869ed34b9bbfdaf7
BLAKE2b-256 checksum
How to use checksums
e63c50b95105d0578ea519d8d586a810a67c218db496ca77efa59f849f951480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp38-cp38-win_amd64.whl
Size 715.8 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
06092f06e4b8a1f2563df03214c9f6fa457c9ff6d114f76bf9fb374cc2a4591f
BLAKE2b-256 checksum
How to use checksums
d93c5be641241b1cb91ce65d77febcee76a8ec1a66244d2f75172212bfd692ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / OpenCC-1.1.7-cp38-cp38-manylinux1_x86_64.whl

Download URL OpenCC-1.1.7-cp38-cp38-manylinux1_x86_64.whl
Size 779.8 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
49bbf40042702a743ad5b65398fc3faf1582e41fc948cd9bbbabe7c3e5366cd6
BLAKE2b-256 checksum
How to use checksums
7c19b05d2c0b0f03154e68e85086e1db891b785afadfaad3901294fff6c19572
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

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

Download URL OpenCC-1.1.7-cp38-cp38-macosx_10_9_x86_64.whl
Size 734.8 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
49c2eb39f636c948eaa21a84f4553da761a9cca5aa0dede8570729d572712531
BLAKE2b-256 checksum
How to use checksums
dafded04905f54eb29459f91ee8afc10de9342a0a09fcba40dcc5bb2b272c895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.18

Security for OpenCC 1.1.7

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