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 安裝

Package Managers 包管理器

Prebuilt 預編譯

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

pip install opencc (Windows, Linux, macOS)

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;
}

Full example with Bazel

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 & macOS

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

make

Windows Visual Studio:

build.cmd

Build with Bazel

bazel build //:opencc

Test 測試

Linux & macOS

make test

Windows Visual Studio:

test.cmd

Test with Bazel

bazel test --test_output=all //src/... //data/... //python/... //test/...

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.2.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 OpenCC 1.2.0
File Size Uploaded Provenance Actions
opencc-1.2.0.tar.gz 3.4 MB Without provenance Details for opencc-1.2.0.tar.gz

Built distributions (wheels)

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

Total release size: 27.4 MB

Release files / opencc-1.2.0.tar.gz

Download URL opencc-1.2.0.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
2bb913c7ed388466b26d38af4c8c4bb419ddb503235d070f0ee1b24998ef8bca
BLAKE2b-256 checksum
How to use checksums
fa9292f4519221b833801be1d037cde747f04c4e29e33bd7574b36b898d9e2bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp312-cp312-win_amd64.whl

Download URL opencc-1.2.0-cp312-cp312-win_amd64.whl
Size 1.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
76cf42a9666ac5402478f7fad2f603d253096aa5c41199b173e08d49a9af8046
BLAKE2b-256 checksum
How to use checksums
d0f60900195298326bd038469f3db571afd73b893a30fe92648f6418162a4cb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / opencc-1.2.0-cp312-cp312-manylinux2014_x86_64.whl

Download URL opencc-1.2.0-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
1f105a05fc76c29a1090cb613996aef26b60525e745e8471dc4485dfe17f2e08
BLAKE2b-256 checksum
How to use checksums
f3f8fc8c5f25243a886dcf15329060e3596e4ab967ee2e277920e4feb6067211
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL opencc-1.2.0-cp312-cp312-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c9851a7b7d50e4c5d52c71972cedbb618542a342ed57ce396be8988bfefdf040
BLAKE2b-256 checksum
How to use checksums
f289c3654977ae86211342356c5f455a26d93dd47222c2444e945aab6a4f91cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp311-cp311-win_amd64.whl

Download URL opencc-1.2.0-cp311-cp311-win_amd64.whl
Size 1.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
f6b631419fae0a1d590eb605699c0507d7f3e43b4e601555d12bf59043dc34d1
BLAKE2b-256 checksum
How to use checksums
21d2d25fce5e58204fbe7722684b49cfd896bd01e11f1a31cec417c19b39bea5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / opencc-1.2.0-cp311-cp311-manylinux2014_x86_64.whl

Download URL opencc-1.2.0-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
6ab92dc34be23a710e98162347287d152bb8ac2ed62fc646dc70a1ab44e2540f
BLAKE2b-256 checksum
How to use checksums
2fe9fa3308bae32fd4f2c5539703a96500aee8006cfcfa975a77106c0fd1e553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL opencc-1.2.0-cp311-cp311-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
696fc0fd0fe4ee1d678c4783af07733425299bc1ed70e55595275d15087006dd
BLAKE2b-256 checksum
How to use checksums
abf99c70995ba3b9839b5754bd3fe4b7bad46b252a343601e17bcac21d86ce6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp310-cp310-win_amd64.whl

Download URL opencc-1.2.0-cp310-cp310-win_amd64.whl
Size 1.8 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
127437a9173bea7be78bb722a2705238ec7a53cf576a7e20312407abe0a28a45
BLAKE2b-256 checksum
How to use checksums
dd631d1a91d1b913e600c8d65c302ba445a22bcbba9f38f23addbc5a77ca6e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / opencc-1.2.0-cp310-cp310-manylinux2014_x86_64.whl

Download URL opencc-1.2.0-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
cd62b27d50d057194fea66e066b558362d0c543739a32a4d2ccef11a3b7c2a07
BLAKE2b-256 checksum
How to use checksums
03ab7f73fc8a7d62091d7b01fb2b21708dfd38df429b058b9767abddce7d0b87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL opencc-1.2.0-cp310-cp310-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
909a7902d09333509a4bf31f3bb5dd21c5cbdde966601a3ae69a3f38c1d8a6c0
BLAKE2b-256 checksum
How to use checksums
c7eecbb613d82921d214fb789b4b0a539d8be6b5392e1b6591cf566dcd13be92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp39-cp39-win_amd64.whl

Download URL opencc-1.2.0-cp39-cp39-win_amd64.whl
Size 1.8 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
fd4c89a82d21cd579e8de1af5883dc4e7b1333278f38723990f59e5a3f96d5d5
BLAKE2b-256 checksum
How to use checksums
f864408aad97be72d17c045259dba3d152acb74c0e1fe08a4be300e7dc3e7c3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / opencc-1.2.0-cp39-cp39-manylinux2014_x86_64.whl

Download URL opencc-1.2.0-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
400d18c3c989fff68701be9d059bf133a6338d4f602991d3fdf4eb1a7939d518
BLAKE2b-256 checksum
How to use checksums
8b1dd612dca998868bfe9874bfd16bd3f2126c4e5a6b13e101c88bc4773459aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL opencc-1.2.0-cp39-cp39-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
66b02f91a53532267328a88d7013309ac7504c13bf957385c84107fe4d028317
BLAKE2b-256 checksum
How to use checksums
ac984577b64b2af5856200021f0883f28a003dd9421c4426dddf823c798ebc89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp38-cp38-win_amd64.whl

Download URL opencc-1.2.0-cp38-cp38-win_amd64.whl
Size 1.8 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
d803ba9934af2eb0570f91f6115b691cab121310bd0cac4de9ee86dc572f1067
BLAKE2b-256 checksum
How to use checksums
76ae9d4a0309f6741017c10637095c8dd4d4ac7de7db67721f386051bca0d8aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / opencc-1.2.0-cp38-cp38-manylinux2014_x86_64.whl

Download URL opencc-1.2.0-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
57860f546b9f8ad4ddc6fa5d53e09f933c7a238a0f13c7f94b4505592edc3b31
BLAKE2b-256 checksum
How to use checksums
72f64563ad22f1d8433b6399f7c573c9151786f4c67e08dabe13ed89fb2dc7d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / opencc-1.2.0-cp38-cp38-macosx_11_0_arm64.whl

Download URL opencc-1.2.0-cp38-cp38-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e94d080069f0e3e387fcd12c6b07cea2f50201d8af69cfd6de62b20e34bf6875
BLAKE2b-256 checksum
How to use checksums
4133529ed3632e46efe7da09efe7ae19acbfe0f5b951fc0cf00f92d3d28fa894
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Security for OpenCC 1.2.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.

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