FPDF utf-8 编码 (HOW-TO) [英] FPDF utf-8 encoding (HOW-TO)
问题描述
有谁知道如何将FPDF包中的编码设置为UTF-8?或者至少是支持希腊字符的 ISO-8859-7(希腊语)?
Does anybody know how to set the encoding in FPDF package to UTF-8? Or at least to ISO-8859-7 (Greek) that supports Greek characters?
基本上我想创建一个包含希腊字符的 PDF 文件.
Basically I want to create a PDF file containing Greek characters.
任何建议都会有所帮助.乔治
Any suggestions would help. George
推荐答案
不要使用 UTF-8 编码.标准 FPDF 字体使用 ISO-8859-1 或 Windows-1252.可以使用 utf8_decode()
执行到 ISO-8859-1 的转换:$str = utf8_decode($str);
但是某些字符(例如 Euro)将无法正确翻译.如果 iconv 扩展可用,正确的方法如下:$str = iconv('UTF-8', 'windows-1252', $str);
Don't use UTF-8 encoding. Standard FPDF fonts use ISO-8859-1 or Windows-1252. It is possible to perform a conversion to ISO-8859-1 with utf8_decode()
:
$str = utf8_decode($str);
But some characters such as Euro won't be translated correctly. If the iconv extension is available, the right way to do it is the following:
$str = iconv('UTF-8', 'windows-1252', $str);
这篇关于FPDF utf-8 编码 (HOW-TO)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!