无法通过 TCPDF 为某些特定的简体中文字符生成 PDF [英] Cannot generate PDF for some specific simplified chinese characters via TCPDF
问题描述
我有一个现有的程序(代码)可以通过 TCPDF 生成 PDF 文件.它在大多数情况下甚至包含非英文字符也能正常工作,但是现在,当内容包含两个简体中文字符 喆
(unicode 编号:21894)或 旻
(unicodenumber: 26107),所有汉字将转换为矩形(无效字符).
I have an existing program (codes) to generate PDF file via TCPDF. It works fine even contain non-English characters in most cases, but now, when the content has either two simplified Chinese characters 喆
(unicode number: 21894) or 旻
(unicode number: 26107), all Chinese characters will be converted to rectangle (invalid character).
我尝试查看uni2cid_ag15.php,可以找到这两个词的映射,并且映射的cid是正确的.有没有人知道将汉字错误地转换为特定字符的原因?
I tried to check the uni2cid_ag15.php, and I can find the mapping of those two words and the mapped cids are correct. Is anyone know the reason for converting the Chinese characters incorrectly with that specific character(s)?
参考文献:
https://raw.githubusercontent.com/adobe-type-tools/cmap-resources/master/cmapresources_gb1-5/cid2code.txt
https://github.com/tecnickcom/TCPDF/blob/master/字体/uni2cid_ag15.php
提前感谢您的建议.
推荐答案
我通过为 php 函数 mb_convert_encoding 使用新的编码GB18030"而不是GB2312"找到了解决方案.这些字符可以毫无问题地在 PDF 中生成.
I found out the solution by using new encoding "GB18030" for php function mb_convert_encoding, instead of "GB2312". Those characters can be generated in the PDF without problem.
这篇关于无法通过 TCPDF 为某些特定的简体中文字符生成 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!