Skip to content

opencc

OpenCC conversion between Simplified Chinese, Traditional Chinese, regional variants and Japanese Shinjitai

pg_opencc · OpenCC conversion between Simplified Chinese, Traditional Chinese, regional variants and Japanese Shinjitai

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4480openccpg_opencc0.1.0UTILApache-2.0C++
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-dt-NoYesNoYesnoyes
Relationships
Schemasopencc
UTF8; bundled OpenCC 1.4.2.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.1.019 18 17 16 15pg_opencc-
RPMPIGSTY0.1.019 18 17 16 15pg_opencc_$v-
DEBPIGSTY0.1.019 18 17 16 15postgresql-$v-opencc-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el8.aarch64N/APIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el9.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el9.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el10.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
el10.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d12.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d12.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d13.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
d13.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u22.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u22.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u24.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u24.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u26.x86_64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
u26.aarch64PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0PIGSTY 0.1.0
PackageVersionOSORGSIZEFile URL
pg_opencc_190.1.0el9.x86_64pigsty798.8 KiBpg_opencc_19-0.1.0-1PGSTY.el9.x86_64.rpm
pg_opencc_190.1.0el9.aarch64pigsty781.2 KiBpg_opencc_19-0.1.0-1PGSTY.el9.aarch64.rpm
pg_opencc_190.1.0el10.x86_64pigsty812.8 KiBpg_opencc_19-0.1.0-1PGSTY.el10.x86_64.rpm
pg_opencc_190.1.0el10.aarch64pigsty790.0 KiBpg_opencc_19-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-opencc0.1.0d12.x86_64pigsty783.6 KiBpostgresql-19-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-opencc0.1.0d12.aarch64pigsty748.8 KiBpostgresql-19-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-opencc0.1.0d13.x86_64pigsty802.5 KiBpostgresql-19-opencc_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-opencc0.1.0d13.aarch64pigsty763.5 KiBpostgresql-19-opencc_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-opencc0.1.0u22.x86_64pigsty774.5 KiBpostgresql-19-opencc_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-opencc0.1.0u22.aarch64pigsty764.2 KiBpostgresql-19-opencc_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-opencc0.1.0u24.x86_64pigsty763.0 KiBpostgresql-19-opencc_0.1.0-1PGSTY~noble_amd64.deb
postgresql-19-opencc0.1.0u24.aarch64pigsty752.6 KiBpostgresql-19-opencc_0.1.0-1PGSTY~noble_arm64.deb
postgresql-19-opencc0.1.0u26.x86_64pigsty769.8 KiBpostgresql-19-opencc_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-opencc0.1.0u26.aarch64pigsty761.9 KiBpostgresql-19-opencc_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_opencc_180.1.0el8.x86_64pigsty890.4 KiBpg_opencc_18-0.1.0-1PGSTY.el8.x86_64.rpm
pg_opencc_180.1.0el8.aarch64pigsty850.7 KiBpg_opencc_18-0.1.0-1PGSTY.el8.aarch64.rpm
pg_opencc_180.1.0el9.x86_64pigsty798.7 KiBpg_opencc_18-0.1.0-1PGSTY.el9.x86_64.rpm
pg_opencc_180.1.0el9.aarch64pigsty781.0 KiBpg_opencc_18-0.1.0-1PGSTY.el9.aarch64.rpm
pg_opencc_180.1.0el10.x86_64pigsty813.0 KiBpg_opencc_18-0.1.0-1PGSTY.el10.x86_64.rpm
pg_opencc_180.1.0el10.aarch64pigsty790.5 KiBpg_opencc_18-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-opencc0.1.0d12.x86_64pigsty783.9 KiBpostgresql-18-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-opencc0.1.0d12.aarch64pigsty749.6 KiBpostgresql-18-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-opencc0.1.0d13.x86_64pigsty802.6 KiBpostgresql-18-opencc_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-opencc0.1.0d13.aarch64pigsty764.2 KiBpostgresql-18-opencc_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-opencc0.1.0u22.x86_64pigsty774.9 KiBpostgresql-18-opencc_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-opencc0.1.0u22.aarch64pigsty764.1 KiBpostgresql-18-opencc_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-opencc0.1.0u24.x86_64pigsty764.0 KiBpostgresql-18-opencc_0.1.0-1PGSTY~noble_amd64.deb
postgresql-18-opencc0.1.0u24.aarch64pigsty753.6 KiBpostgresql-18-opencc_0.1.0-1PGSTY~noble_arm64.deb
postgresql-18-opencc0.1.0u26.x86_64pigsty770.2 KiBpostgresql-18-opencc_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-opencc0.1.0u26.aarch64pigsty761.9 KiBpostgresql-18-opencc_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_opencc_170.1.0el8.x86_64pigsty890.4 KiBpg_opencc_17-0.1.0-1PGSTY.el8.x86_64.rpm
pg_opencc_170.1.0el8.aarch64pigsty850.8 KiBpg_opencc_17-0.1.0-1PGSTY.el8.aarch64.rpm
pg_opencc_170.1.0el9.x86_64pigsty798.7 KiBpg_opencc_17-0.1.0-1PGSTY.el9.x86_64.rpm
pg_opencc_170.1.0el9.aarch64pigsty780.9 KiBpg_opencc_17-0.1.0-1PGSTY.el9.aarch64.rpm
pg_opencc_170.1.0el10.x86_64pigsty813.0 KiBpg_opencc_17-0.1.0-1PGSTY.el10.x86_64.rpm
pg_opencc_170.1.0el10.aarch64pigsty790.3 KiBpg_opencc_17-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-opencc0.1.0d12.x86_64pigsty784.2 KiBpostgresql-17-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-opencc0.1.0d12.aarch64pigsty749.3 KiBpostgresql-17-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-opencc0.1.0d13.x86_64pigsty802.8 KiBpostgresql-17-opencc_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-opencc0.1.0d13.aarch64pigsty764.3 KiBpostgresql-17-opencc_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-opencc0.1.0u22.x86_64pigsty778.5 KiBpostgresql-17-opencc_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-opencc0.1.0u22.aarch64pigsty767.6 KiBpostgresql-17-opencc_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-opencc0.1.0u24.x86_64pigsty764.1 KiBpostgresql-17-opencc_0.1.0-1PGSTY~noble_amd64.deb
postgresql-17-opencc0.1.0u24.aarch64pigsty754.1 KiBpostgresql-17-opencc_0.1.0-1PGSTY~noble_arm64.deb
postgresql-17-opencc0.1.0u26.x86_64pigsty770.1 KiBpostgresql-17-opencc_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-opencc0.1.0u26.aarch64pigsty762.1 KiBpostgresql-17-opencc_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_opencc_160.1.0el8.x86_64pigsty890.3 KiBpg_opencc_16-0.1.0-1PGSTY.el8.x86_64.rpm
pg_opencc_160.1.0el8.aarch64pigsty850.7 KiBpg_opencc_16-0.1.0-1PGSTY.el8.aarch64.rpm
pg_opencc_160.1.0el9.x86_64pigsty798.7 KiBpg_opencc_16-0.1.0-1PGSTY.el9.x86_64.rpm
pg_opencc_160.1.0el9.aarch64pigsty781.0 KiBpg_opencc_16-0.1.0-1PGSTY.el9.aarch64.rpm
pg_opencc_160.1.0el10.x86_64pigsty813.1 KiBpg_opencc_16-0.1.0-1PGSTY.el10.x86_64.rpm
pg_opencc_160.1.0el10.aarch64pigsty790.4 KiBpg_opencc_16-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-opencc0.1.0d12.x86_64pigsty783.9 KiBpostgresql-16-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-opencc0.1.0d12.aarch64pigsty749.2 KiBpostgresql-16-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-opencc0.1.0d13.x86_64pigsty802.8 KiBpostgresql-16-opencc_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-opencc0.1.0d13.aarch64pigsty764.1 KiBpostgresql-16-opencc_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-opencc0.1.0u22.x86_64pigsty778.5 KiBpostgresql-16-opencc_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-opencc0.1.0u22.aarch64pigsty767.5 KiBpostgresql-16-opencc_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-opencc0.1.0u24.x86_64pigsty764.1 KiBpostgresql-16-opencc_0.1.0-1PGSTY~noble_amd64.deb
postgresql-16-opencc0.1.0u24.aarch64pigsty754.2 KiBpostgresql-16-opencc_0.1.0-1PGSTY~noble_arm64.deb
postgresql-16-opencc0.1.0u26.x86_64pigsty770.0 KiBpostgresql-16-opencc_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-opencc0.1.0u26.aarch64pigsty762.1 KiBpostgresql-16-opencc_0.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_opencc_150.1.0el8.x86_64pigsty890.5 KiBpg_opencc_15-0.1.0-1PGSTY.el8.x86_64.rpm
pg_opencc_150.1.0el8.aarch64pigsty850.5 KiBpg_opencc_15-0.1.0-1PGSTY.el8.aarch64.rpm
pg_opencc_150.1.0el9.x86_64pigsty798.8 KiBpg_opencc_15-0.1.0-1PGSTY.el9.x86_64.rpm
pg_opencc_150.1.0el9.aarch64pigsty780.9 KiBpg_opencc_15-0.1.0-1PGSTY.el9.aarch64.rpm
pg_opencc_150.1.0el10.x86_64pigsty813.2 KiBpg_opencc_15-0.1.0-1PGSTY.el10.x86_64.rpm
pg_opencc_150.1.0el10.aarch64pigsty790.5 KiBpg_opencc_15-0.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-opencc0.1.0d12.x86_64pigsty783.8 KiBpostgresql-15-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-opencc0.1.0d12.aarch64pigsty749.5 KiBpostgresql-15-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-opencc0.1.0d13.x86_64pigsty802.7 KiBpostgresql-15-opencc_0.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-opencc0.1.0d13.aarch64pigsty764.2 KiBpostgresql-15-opencc_0.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-opencc0.1.0u22.x86_64pigsty778.4 KiBpostgresql-15-opencc_0.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-opencc0.1.0u22.aarch64pigsty767.5 KiBpostgresql-15-opencc_0.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-opencc0.1.0u24.x86_64pigsty764.1 KiBpostgresql-15-opencc_0.1.0-1PGSTY~noble_amd64.deb
postgresql-15-opencc0.1.0u24.aarch64pigsty754.1 KiBpostgresql-15-opencc_0.1.0-1PGSTY~noble_arm64.deb
postgresql-15-opencc0.1.0u26.x86_64pigsty770.1 KiBpostgresql-15-opencc_0.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-opencc0.1.0u26.aarch64pigsty762.2 KiBpostgresql-15-opencc_0.1.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_opencc;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_opencc;		# install by package name
pig install opencc;		# install by extension name

pig install opencc -v 19;   # install for PG 19
pig install opencc -v 18;   # install for PG 18
pig install opencc -v 17;   # install for PG 17
pig install opencc -v 16;   # install for PG 16
pig install opencc -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION opencc;

Usage

Sources:

opencc, distributed as pg_opencc, converts Simplified Chinese, Traditional Chinese, Taiwan and Hong Kong conventions, and Japanese Shinjitai. Version 0.1.0 embeds OpenCC 1.4.2 and its dictionaries in the shared library; no system OpenCC or external dictionary files are required at runtime.

Enable and convert

Supports PostgreSQL 14–18 and requires a UTF8 database. This trusted extension can be installed by a user with CREATE privilege on the database. Objects use the fixed opencc schema; the extension is not relocatable. Preloading and a server restart are not required.

CREATE EXTENSION opencc;

SELECT opencc.s2twp('鼠标里面的硅二极管坏了,导致光标分辨率降低。');
SELECT opencc.convert('繁體中文', 't2s');
SELECT * FROM opencc.configs;

opencc.convert(input, config) selects a conversion explicitly. Wrappers such as opencc.s2t() and opencc.t2s() provide one function per configuration:

ConfigurationsConversion
s2t, t2sSimplified and Traditional Chinese
s2tw, tw2s, s2hk, hk2sTaiwan or Hong Kong character conventions
s2twp, tw2spTaiwan regional phrases
s2hkp, hk2spHong Kong regional phrases; developing
t2tw, tw2t, t2hk, hk2tTraditional Chinese variant conversion
t2jp, jp2tJapanese old/new character forms; experimental

Regional conversion and inspection

opencc.localize(input, target, source) accepts zh-Hans, zh-Hant, zh-CN, zh-TW, zh-HK, and ja. Its default source => 'auto' detects the script, but cannot distinguish Taiwan from Hong Kong vocabulary. Supply the source region when regional phrases matter.

SELECT opencc.localize('滑鼠裡面的矽二極體壞了', 'zh-CN', source => 'zh-TW');
SELECT opencc.detect('中文'), opencc.script_stats('中文');
SELECT * FROM opencc.routes;
SELECT * FROM opencc.ambiguities('大战文丑的时候,他的头发很干燥', 's2t');
SELECT opencc.candidates('发', 's2t');
SELECT * FROM opencc.explain('数据库连接池', 's2twp');
ObjectPurpose
opencc.detect()Classify the script, including mixed or neutral text
opencc.script_stats()Count Han, simplified, traditional, and kana characters
opencc.configs, opencc.routesInspect configurations and regional conversion chains
opencc.ambiguities(), opencc.candidates()Inspect ambiguous spans and dictionary candidates
opencc.explain()Inspect each conversion stage
opencc.version()Report extension, engine, and dictionary digest
opencc.dependents()Find dependent database objects and suggested rebuild statements

Operation and upgrades

Conversion functions are IMMUTABLE STRICT PARALLEL SAFE within an extension version. They can be used in expression indexes and stored generated columns. PostgreSQL 18 generated columns must explicitly use STORED for user-defined conversion functions.

Dictionary changes in a future extension release can change conversion results. Inspect opencc.version() and review the statements returned by opencc.dependents() when upgrading. Dependency discovery does not find calls hidden inside other user-defined functions.

SELECT * FROM opencc.version();
SELECT * FROM opencc.dependents();

Each backend initializes converters on demand. Optional startup preloading can share their memory across backends; changing shared_preload_libraries requires a restart:

shared_preload_libraries = 'opencc'
opencc.preload = 's2t,t2s,s2twp,tw2sp'

Merge opencc into any existing preload list. opencc.preload also accepts all. Dropping the extension leaves its empty schema behind.

Table reader