opencc
pg_opencc : OpenCC conversion between Simplified Chinese, Traditional Chinese, regional variants and Japanese Shinjitai
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4480 | opencc | pg_opencc | 0.1.0 |
UTIL | Apache-2.0 AND BSD-2-Clause AND MIT | C++ |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-dt- | No | Yes | No | Yes | no | yes |
| Relationships | |
|---|---|
| Schemas | opencc |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el8.aarch64 | N/A | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el9.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el9.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el10.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el10.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d12.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d12.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d13.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d13.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u22.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u22.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u24.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u24.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u26.x86_64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u26.aarch64 | MISS | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
Source
github.com/pgsty/pg_opencc
pg_opencc-0.1.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
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.
opencc.convert(input, config) selects a conversion explicitly. Wrappers such as opencc.s2t() and opencc.t2s() provide one function per configuration:
| Configurations | Conversion |
|---|---|
s2t, t2s |
Simplified and Traditional Chinese |
s2tw, tw2s, s2hk, hk2s |
Taiwan or Hong Kong character conventions |
s2twp, tw2sp |
Taiwan regional phrases |
s2hkp, hk2sp |
Hong Kong regional phrases; developing |
t2tw, tw2t, t2hk, hk2t |
Traditional Chinese variant conversion |
t2jp, jp2t |
Japanese 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.
| Object | Purpose |
|---|---|
opencc.detect() |
Classify the script, including mixed or neutral text |
opencc.script_stats() |
Count Han, simplified, traditional, and kana characters |
opencc.configs, opencc.routes |
Inspect 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.
Each backend initializes converters on demand. Optional startup preloading can share their memory across backends; changing shared_preload_libraries requires a restart:
Merge opencc into any existing preload list. opencc.preload also accepts all. Dropping the extension leaves its empty schema behind.