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 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 版本歷史

Links 相關鏈接

Contributors 貢獻者

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

Metadata

Release files for OpenCC 1.1.3

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.3
File Actions
OpenCC-1.1.3-cp39-cp39-manylinux1_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-64 Details for OpenCC-1.1.3-cp39-cp39-manylinux1_x86_64.whl
OpenCC-1.1.3-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details for OpenCC-1.1.3-cp39-cp39-macosx_10_9_x86_64.whl
OpenCC-1.1.3-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details for OpenCC-1.1.3-cp38-cp38-manylinux1_x86_64.whl
OpenCC-1.1.3-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details for OpenCC-1.1.3-cp38-cp38-macosx_10_9_x86_64.whl
OpenCC-1.1.3-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details for OpenCC-1.1.3-cp37-cp37m-manylinux1_x86_64.whl
OpenCC-1.1.3-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details for OpenCC-1.1.3-cp37-cp37m-macosx_10_9_x86_64.whl
OpenCC-1.1.3-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details for OpenCC-1.1.3-cp36-cp36m-manylinux1_x86_64.whl
OpenCC-1.1.3-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details for OpenCC-1.1.3-cp36-cp36m-macosx_10_9_x86_64.whl
OpenCC-1.1.3-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details for OpenCC-1.1.3-cp35-cp35m-manylinux1_x86_64.whl
OpenCC-1.1.3-cp35-cp35m-macosx_10_9_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64 Details for OpenCC-1.1.3-cp35-cp35m-macosx_10_9_x86_64.whl
OpenCC-1.1.3-cp27-cp27mu-manylinux1_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64 Details for OpenCC-1.1.3-cp27-cp27mu-manylinux1_x86_64.whl
OpenCC-1.1.3-cp27-cp27m-macosx_10_9_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.9+ x86-64 Details for OpenCC-1.1.3-cp27-cp27m-macosx_10_9_x86_64.whl

Total release size: 9.0 MB

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

Download URL OpenCC-1.1.3-cp39-cp39-manylinux1_x86_64.whl
Size 766.4 kB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
48309ed913fde331f43beea36ca74252f1e279ee98d149f8509151a2252adbca
BLAKE2b-256 checksum
How to use checksums
a37ea54f295b142b18b4812d122350ef0a8fd6328504b582cf279c22118d5bae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

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

Download URL OpenCC-1.1.3-cp39-cp39-macosx_10_9_x86_64.whl
Size 728.1 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
3aadc356b3b67dead0614fd47530351130eddf0d45b9889a5b58dd888c945640
BLAKE2b-256 checksum
How to use checksums
563ccd5b9f819f41573e244563fb681e648fdf08a4f1ae0accf3d1400d97d2c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

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

Download URL OpenCC-1.1.3-cp38-cp38-manylinux1_x86_64.whl
Size 766.4 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2d1043e4d19ac89656b83e027f1834451ee0639d27239b579ba0b7cbb24af805
BLAKE2b-256 checksum
How to use checksums
bf13d527a8b9ef33400f3e99b3bcc31ae2552768ff0114462ecd16a63dfc8f53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

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

Download URL OpenCC-1.1.3-cp38-cp38-macosx_10_9_x86_64.whl
Size 728.1 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c0a85bb12f362903241a53c767838fe09d494c4caffe12797157bdd8133b7e6e
BLAKE2b-256 checksum
How to use checksums
99a860ff0718d310c66bae689777ec2c907a4e022f73b43d064e382703631ebf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp37-cp37m-manylinux1_x86_64.whl

Download URL OpenCC-1.1.3-cp37-cp37m-manylinux1_x86_64.whl
Size 766.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
78cf0874896bb686f9d1b9dc612b911118db99ef96567cbf98f61a817c4312c7
BLAKE2b-256 checksum
How to use checksums
4e5dcb2b7e00462561250d903ccbd13916b458f8db067998414542f896db47d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.3-cp37-cp37m-macosx_10_9_x86_64.whl
Size 727.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
7b61cead7f1fba11d027804b706e087ad14da981192c7e0f51e768cbcf2ea22b
BLAKE2b-256 checksum
How to use checksums
c970e805c63455b937410cfbdc9606188cb07040b12482f4bcd087e235e57527
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp36-cp36m-manylinux1_x86_64.whl

Download URL OpenCC-1.1.3-cp36-cp36m-manylinux1_x86_64.whl
Size 766.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d3551e5ed3939129fbb8cfb244de6924892d2f950009e666f0d4e7aec53ca953
BLAKE2b-256 checksum
How to use checksums
819166b80972bd03800ff86d9d38da2ef51911145a342cc53b1bf67265f6fe91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.3-cp36-cp36m-macosx_10_9_x86_64.whl
Size 727.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
a7e7ef677c107a915f649847a9e901703b099e8dac643e34c0dee14cca0d748a
BLAKE2b-256 checksum
How to use checksums
389eb52cbfcb7a073e6508a8c68bf793c2e27ee14afc680c1528f5cccf50dbe0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp35-cp35m-manylinux1_x86_64.whl

Download URL OpenCC-1.1.3-cp35-cp35m-manylinux1_x86_64.whl
Size 766.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
94d95dce79c6ba3d4143d66f854e160e07ca5be571d4cbac555f4b2ffad7f837
BLAKE2b-256 checksum
How to use checksums
009b68629450519e58b153cf8d195f29155848d9bf267729c1849682668f94f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp35-cp35m-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.3-cp35-cp35m-macosx_10_9_x86_64.whl
Size 727.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f21fe97c3d06568b31a65a9b9138d454424fb37565c9ae7105347ec8fa1ec90c
BLAKE2b-256 checksum
How to use checksums
1999f570aae1be1593657a33aa7bfdba3db9f3181043da502df6057370dd7ac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp27-cp27mu-manylinux1_x86_64.whl

Download URL OpenCC-1.1.3-cp27-cp27mu-manylinux1_x86_64.whl
Size 766.3 kB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
1db67f6950fe40ab6c20c560808508a2afa049361908cf0bd39f33bdbcab77de
BLAKE2b-256 checksum
How to use checksums
f12ac0122f36f8b8deb609bfcc419b9c99f9db348d4e2557a8b662dd0b19ed97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release files / OpenCC-1.1.3-cp27-cp27m-macosx_10_9_x86_64.whl

Download URL OpenCC-1.1.3-cp27-cp27m-macosx_10_9_x86_64.whl
Size 728.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
d51d53270fb967211f297d976497ebed1875576502e5ceb8bb4bf86404d5fc53
BLAKE2b-256 checksum
How to use checksums
a9830d79b71e756ee7ecf726a9ed4a2bc6e35ec43892573817fbeb2f7b7b1d5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Security for OpenCC 1.1.3

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