opencc
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
pg_opencc | 0.1.0 | UTIL | Apache-2.0 AND BSD-2-Clause AND MIT | C++ |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 4480 | opencc | 否 | 是 | 否 | 是 | 是 | 否 | opencc |
UTF8; bundled OpenCC 1.4.2.
版本
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.0 el8.x86_64.pg18 : pg_opencc_18 pg_opencc_18-0.1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.1.0 el8.x86_64.pg17 : pg_opencc_17 pg_opencc_17-0.1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.1.0 el8.x86_64.pg16 : pg_opencc_16 pg_opencc_16-0.1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.1.0 el8.x86_64.pg15 : pg_opencc_15 pg_opencc_15-0.1.0-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.1.0 el8.x86_64.pg14 : pg_opencc_14 pg_opencc_14-0.1.0-1PGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 0.1.0 el8.aarch64.pg18 : pg_opencc_18 pg_opencc_18-0.1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.1.0 el8.aarch64.pg17 : pg_opencc_17 pg_opencc_17-0.1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.1.0 el8.aarch64.pg16 : pg_opencc_16 pg_opencc_16-0.1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.1.0 el8.aarch64.pg15 : pg_opencc_15 pg_opencc_15-0.1.0-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.1.0 el8.aarch64.pg14 : pg_opencc_14 pg_opencc_14-0.1.0-1PGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 0.1.0 el9.x86_64.pg18 : pg_opencc_18 pg_opencc_18-0.1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.1.0 el9.x86_64.pg17 : pg_opencc_17 pg_opencc_17-0.1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.1.0 el9.x86_64.pg16 : pg_opencc_16 pg_opencc_16-0.1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.1.0 el9.x86_64.pg15 : pg_opencc_15 pg_opencc_15-0.1.0-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.1.0 el9.x86_64.pg14 : pg_opencc_14 pg_opencc_14-0.1.0-1PGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 0.1.0 el9.aarch64.pg18 : pg_opencc_18 pg_opencc_18-0.1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.1.0 el9.aarch64.pg17 : pg_opencc_17 pg_opencc_17-0.1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.1.0 el9.aarch64.pg16 : pg_opencc_16 pg_opencc_16-0.1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.1.0 el9.aarch64.pg15 : pg_opencc_15 pg_opencc_15-0.1.0-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.1.0 el9.aarch64.pg14 : pg_opencc_14 pg_opencc_14-0.1.0-1PGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 0.1.0 el10.x86_64.pg18 : pg_opencc_18 pg_opencc_18-0.1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.1.0 el10.x86_64.pg17 : pg_opencc_17 pg_opencc_17-0.1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.1.0 el10.x86_64.pg16 : pg_opencc_16 pg_opencc_16-0.1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.1.0 el10.x86_64.pg15 : pg_opencc_15 pg_opencc_15-0.1.0-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.1.0 el10.x86_64.pg14 : pg_opencc_14 pg_opencc_14-0.1.0-1PGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 0.1.0 el10.aarch64.pg18 : pg_opencc_18 pg_opencc_18-0.1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.1.0 el10.aarch64.pg17 : pg_opencc_17 pg_opencc_17-0.1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.1.0 el10.aarch64.pg16 : pg_opencc_16 pg_opencc_16-0.1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.1.0 el10.aarch64.pg15 : pg_opencc_15 pg_opencc_15-0.1.0-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.1.0 el10.aarch64.pg14 : pg_opencc_14 pg_opencc_14-0.1.0-1PGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 0.1.0 d12.x86_64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.1.0 d12.x86_64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.1.0 d12.x86_64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.1.0 d12.x86_64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.1.0 d12.x86_64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 0.1.0 d12.aarch64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.1.0 d12.aarch64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.1.0 d12.aarch64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.1.0 d12.aarch64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.1.0 d12.aarch64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 0.1.0 d13.x86_64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 0.1.0 d13.x86_64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 0.1.0 d13.x86_64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 0.1.0 d13.x86_64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~trixie_amd64.deb
| PIGSTY 0.1.0 d13.x86_64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 0.1.0 d13.aarch64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 0.1.0 d13.aarch64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 0.1.0 d13.aarch64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 0.1.0 d13.aarch64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~trixie_arm64.deb
| PIGSTY 0.1.0 d13.aarch64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 0.1.0 u22.x86_64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 0.1.0 u22.x86_64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 0.1.0 u22.x86_64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 0.1.0 u22.x86_64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~jammy_amd64.deb
| PIGSTY 0.1.0 u22.x86_64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 0.1.0 u22.aarch64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 0.1.0 u22.aarch64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 0.1.0 u22.aarch64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 0.1.0 u22.aarch64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~jammy_arm64.deb
| PIGSTY 0.1.0 u22.aarch64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 0.1.0 u24.x86_64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~noble_amd64.deb
| PIGSTY 0.1.0 u24.x86_64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~noble_amd64.deb
| PIGSTY 0.1.0 u24.x86_64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~noble_amd64.deb
| PIGSTY 0.1.0 u24.x86_64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~noble_amd64.deb
| PIGSTY 0.1.0 u24.x86_64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 0.1.0 u24.aarch64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~noble_arm64.deb
| PIGSTY 0.1.0 u24.aarch64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~noble_arm64.deb
| PIGSTY 0.1.0 u24.aarch64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~noble_arm64.deb
| PIGSTY 0.1.0 u24.aarch64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~noble_arm64.deb
| PIGSTY 0.1.0 u24.aarch64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY 0.1.0 u26.x86_64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 0.1.0 u26.x86_64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 0.1.0 u26.x86_64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 0.1.0 u26.x86_64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~resolute_amd64.deb
| PIGSTY 0.1.0 u26.x86_64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~resolute_amd64.deb
|
| u26.aarch64 | PIGSTY 0.1.0 u26.aarch64.pg18 : postgresql-18-opencc postgresql-18-opencc_0.1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 0.1.0 u26.aarch64.pg17 : postgresql-17-opencc postgresql-17-opencc_0.1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 0.1.0 u26.aarch64.pg16 : postgresql-16-opencc postgresql-16-opencc_0.1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 0.1.0 u26.aarch64.pg15 : postgresql-15-opencc postgresql-15-opencc_0.1.0-1PGSTY~resolute_arm64.deb
| PIGSTY 0.1.0 u26.aarch64.pg14 : postgresql-14-opencc postgresql-14-opencc_0.1.0-1PGSTY~resolute_arm64.deb
|
构建
您可以使用 pig build 命令构建 pg_opencc 扩展的 RPM / DEB 包:
安装
您可以直接安装 pg_opencc 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
使用 pig 或者是 apt/yum/dnf 安装扩展:
创建扩展:
用法
来源:
opencc 由 pg_opencc 项目提供,用于简体中文、繁体中文、台湾与香港用语以及日文新字体之间的转换。0.1.0 版本将 OpenCC 1.4.2 及其词典嵌入共享库,运行时无需系统 OpenCC 或外部词典文件。
启用与转换
支持 PostgreSQL 14–18,要求数据库使用 UTF8 编码。这是受信任扩展,拥有数据库 CREATE 权限的用户即可安装。对象位于固定的 opencc 模式中,扩展不可迁移模式。基本使用无需预加载或重启服务器。
opencc.convert(input, config) 用于明确指定转换配置。opencc.s2t()、opencc.t2s() 等快捷函数与各个配置一一对应:
| 配置 | 转换用途 |
|---|---|
s2t, t2s | 简体中文与繁体中文互转 |
s2tw, tw2s, s2hk, hk2s | 台湾或香港字形转换 |
s2twp, tw2sp | 台湾地区词汇转换 |
s2hkp, hk2sp | 香港地区词汇转换,仍在完善中 |
t2tw, tw2t, t2hk, hk2t | 繁体中文不同地区字形互转 |
t2jp, jp2t | 日文旧字体与新字体互转,实验性功能 |
地区转换与结果检查
opencc.localize(input, target, source) 接受 zh-Hans、zh-Hant、zh-CN、zh-TW、zh-HK 和 ja。默认的 source => 'auto' 可以判断文字类别,但无法区分台湾和香港词汇。需要准确转换地区用语时,应明确指定来源地区。
| 对象 | 用途 |
|---|---|
opencc.detect() | 判断文字类别,包括混合文字与无法区分简繁的文字 |
opencc.script_stats() | 统计汉字、简体字、繁体字和假名 |
opencc.configs, opencc.routes | 检查配置与地区转换链 |
opencc.ambiguities(), opencc.candidates() | 检查歧义片段和词典候选项 |
opencc.explain() | 检查各阶段的转换结果 |
opencc.version() | 返回扩展版本、引擎版本和词典摘要 |
opencc.dependents() | 查找依赖对象并给出建议的重建语句 |
运行与升级
转换函数在同一扩展版本内具有 IMMUTABLE STRICT PARALLEL SAFE 属性,可用于表达式索引和存储生成列。PostgreSQL 18 的生成列若调用自定义转换函数,必须明确指定 STORED。
未来扩展版本更新词典时,转换结果可能变化。升级时应检查 opencc.version(),并审阅 opencc.dependents() 返回的语句。依赖检查无法发现封装在其他自定义函数中的调用。
每个后端按需初始化转换器。也可选择在服务器启动时预加载,使后端共享相关内存;修改 shared_preload_libraries 需要重启:
若已有预加载列表,将 opencc 加入其中。opencc.preload 也接受 all。删除扩展后会保留空模式。
这个页面对您有帮助吗?
感谢反馈,我们会据此改进这篇文档。
哪里没有解决?(可选)