FPDF utf-8编码(HOW-TO) [英] FPDF utf-8 encoding (HOW-TO)
问题描述
有人知道如何设置FPDF包中的编码为utf-8?
Does anybody know how to set the encoding in FPDF package to utf-8? Or at least to ISO-8859-7 (Greek) that support greek characters?
基本上我想创建一个包含希腊字符的pdf文件。
Basically I want to create a pdf file containing greek characters.
任何建议都会有所帮助。
George
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) code>
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屋!