{"id":15029050,"url":"https://github.com/tianliangzhou/ffi-opencc","last_synced_at":"2025-08-11T02:08:28.024Z","repository":{"id":57016865,"uuid":"358493242","full_name":"TianLiangZhou/ffi-opencc","owner":"TianLiangZhou","description":"高性能PHP中文简体繁体互转库","archived":false,"fork":false,"pushed_at":"2024-06-25T01:43:16.000Z","size":1713,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T06:47:53.545Z","etag":null,"topics":["php-ffi","php-opencc","php7"],"latest_commit_sha":null,"homepage":"https://loocode.com/tool/simplified-chinese-to-traditional-chinese","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TianLiangZhou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-16T06:04:38.000Z","updated_at":"2024-03-18T11:55:32.000Z","dependencies_parsed_at":"2025-04-09T20:36:14.889Z","dependency_job_id":"c9f65394-7ca6-4d04-a3dd-c02fca1618f8","html_url":"https://github.com/TianLiangZhou/ffi-opencc","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/TianLiangZhou/ffi-opencc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TianLiangZhou%2Fffi-opencc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TianLiangZhou%2Fffi-opencc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TianLiangZhou%2Fffi-opencc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TianLiangZhou%2Fffi-opencc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TianLiangZhou","download_url":"https://codeload.github.com/TianLiangZhou/ffi-opencc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TianLiangZhou%2Fffi-opencc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269819032,"owners_count":24480087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php-ffi","php-opencc","php7"],"created_at":"2024-09-24T20:09:38.963Z","updated_at":"2025-08-11T02:08:27.997Z","avatar_url":"https://github.com/TianLiangZhou.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ffi-opencc\n\n该项目是将中文简体转换成繁体，使用`rust`构建动态链接库来给`php`调用。\n该库主要是为了提高`php`转换繁体字的性能而构建（__特别是长文章__）。\n\n### 环境\n\n需要`php \u003e= 7.4` 以上的版本并且开启了`FFI`扩展。如果你需要自己编译库还需要装`rust` 工具链。\n\n还需要设置`php.ini` 中的`ffi.enable`为`On`。\n\n该库需要依赖`opencc`库。\n\n目前有两种方式来构建依赖。\n\n1. 手动安装`opencc`\n    \n    \u003e 比如: `yum install opencc` 或者 `apt-get install opencc` 甚至还你可以[自己编译](https://github.com/BYVoid/OpenCC)\n\n2. 为库目录下的`lib/libopencc.so.1.1.2`创建软链\n\n    ```shell\n        [root@meshell]# ln -s ./lib/libopencc.so.1.1.2 /lib64/libopencc.so.1.1\n        [root@meshell]# ln -s /lib64/libopencc.so.1.1 /lib64/libopencc.so\n    ```\n\n\u003e 该目录不支持`window`环境，如果你需要请自行编译。\n\n### Usage\n\n该库提供六种转换用法：简转繁，繁转简，简转繁，繁转简，简转繁，繁转简。\n\n```php\n\u003c?php\n\ninclude __DIR__ . '/../src/OpenCC.php';\n\n// new 方法支持opencc配置目录\n$oc = \\FastFFI\\Opencc\\OpenCC::new();\n\necho \"简体转繁体: \", $oc-\u003es2t(\"头可断，血可流\"), \"\\n\";\n\necho \"繁体转简体: \", $oc-\u003et2s(\"台湾省，是中華人民共和國法定的34個省級行政區之一，也是中華人民共和國法律上的两个岛屿省份之一，其轄區包括臺灣島及其附屬島嶼、澎湖列岛等地\"), \"\\n\";\n\necho \"简体转台正繁体: \", $oc-\u003es2tw(\"头可断，血可流\"), \"\\n\";\n\necho \"台正繁体转简体: \", $oc-\u003etw2s(\"台湾省，是中華人民共和國法定的34個省級行政區之一，也是中華人民共和國法律上的两个岛屿省份之一，其轄區包括臺灣島及其附屬島嶼、澎湖列岛等地\"), \"\\n\";\n\necho \"简体转香港繁体: \", $oc-\u003es2hk(\"头可断，血可流\"), \"\\n\";\n\necho \"香港繁体转简体: \", $oc-\u003ehk2s(\"頭可斷，血可流\"), \"\\n\";\n\n```\n\n以上程序执行后的结果:\n\n\u003e 简体转繁体: 頭可斷，血可流\n\u003e \n\u003e 繁体转简体: 台湾省，是中华人民共和国法定的34个省级行政区之一，也是中华人民共和国法律上的两个岛屿省份之一，其辖区包括台湾岛及其附属岛屿、澎湖列岛等地\n\u003e \n\u003e 简体转台正繁体: 頭可斷，血可流\n\u003e \n\u003e 台正繁体转简体: 台湾省，是中华人民共和国法定的34个省级行政区之一，也是中华人民共和国法律上的两个岛屿省份之一，其辖区包括台湾岛及其附属岛屿、澎湖列岛等地\n\u003e \n\u003e 简体转香港繁体: 頭可斷，血可流\n\u003e \n\u003e 香港繁体转简体: 头可断，血可流\n\n\n[在线转换](http://loocode.com/tool/opencc/simplified-chinese-to-traditional-chinese)\n\n### FAQ\n\n- 在`centos`上执行失败?\n\n  确定是不是`glibc`版本过低。可以使用`ldd lib/libffi_opencc.so` 来查看库信息。\n  如果出现`/lib64/libc.so.6: version 'glibc_2.18' not found`就说明你服务的`glibc`版本过低。\n  下载glibc编译升级，下载地址: `wget http://mirrors.ustc.edu.cn/gnu/libc/glibc-2.18.tar.gz` \n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftianliangzhou%2Fffi-opencc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftianliangzhou%2Fffi-opencc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftianliangzhou%2Fffi-opencc/lists"}