FPDF中的塞尔维亚语字符 [英] Serbian characters in FPDF
问题描述
我对FPDF中的塞尔维亚语言有疑问 http://www.fpdf.org/ >
$ mystring =Запослениурачуноводству/сродномрадномместу";
我用$ pdf-> Write和MultiCell ...都是相同的结果.
utf8_decode($mystring) -> ????????? ? ?????????????/??????? ?????? ?????
iconv('UTF-8', 'utf-8//TRANSLIT', $mystring) -> ЗапÐ3⁄4ѕлÐμÐ1⁄2Ð ̧ у рачуÐ1⁄2Ð3⁄4Ð2Ð3⁄4Ð ́Ñ•Ñ‚Ð2у/Ñ•Ñ€Ð3⁄4Ð ́Ð1⁄2Ð3⁄4Ð1⁄4 раР́Ð1⁄2Ð3⁄4Ð1⁄4Ð1⁄4Ðμѕту
非常感谢
我个人不会在PDF中使用UTF-8,因为文件大小对我来说很大.在这种情况下,我使用字体嵌入来避免大文件.
FPDF类可以用西欧语言以外的其他多种语言生成文档:中欧,西里尔字母,希腊语,波罗的海语和泰语,只要您拥有具有所需字符集的TrueType或Type1字体即可.还提供了UTF-8支持.
要获得UTF-8支持,您必须使用 tFPDF (基于FPDF). tFPDF接受UTF-8编码的文本.请 阅读所有说明 ,然后下载 ZIP文件 在此站点底部.
转换为UTF-8:
如果您使用上面的说明(从链接)并从文件中加载UTF-8字符串,则无需转换为UTF-8,如下所示:
// this file file must be saved in UTF-8 before:
$str = file_get_contents('Text-saved-in-UTF-8.txt');
在其他情况下:
您必须使用 mb_convert_encoding
,而不是iconv
. /p>
对于塞尔维亚语(拉丁语),这是'iso-8859-2'
或'windows-1250'
.对于塞尔维亚语(西里尔字母),这是'iso-8859-5'
或'windows-1251'
.这些编码将提供正确的变音拉丁字符显示,例如žćđš
.
在以下情况下:
$mystring = "Запослени у рачуноводству/сродном радном месту";
您必须写:
$str = mb_convert_encoding($mystring, 'UTF-8', 'iso-8859-5');
或
$str = mb_convert_encoding($mystring, 'UTF-8', 'windows-1251');
您的PHP文件必须先保存在iso-8859-5
或windows-1251
中(但在UTF-8中不).
然后在tFPDF中使用它.
I have problem with Serbian language in FPDF http://www.fpdf.org/
$mystring = "Запослени у рачуноводству/сродном радном месту";
I used $pdf->Write and MultiCell... all are same result.
utf8_decode($mystring) -> ????????? ? ?????????????/??????? ?????? ?????
iconv('UTF-8', 'utf-8//TRANSLIT', $mystring) -> ЗапÐ3⁄4ѕлÐμÐ1⁄2Ð ̧ у рачуÐ1⁄2Ð3⁄4Ð2Ð3⁄4Ð ́Ñ•Ñ‚Ð2у/Ñ•Ñ€Ð3⁄4Ð ́Ð1⁄2Ð3⁄4Ð1⁄4 раР́Ð1⁄2Ð3⁄4Ð1⁄4Ð1⁄4Ðμѕту
thank so much
Personally I would not use UTF-8 in my PDFs because the file size will big for me. I use font embedding in this case to avoid big file size.
The FPDF class can produce documents in many languages other than the Western European ones: Central European, Cyrillic, Greek, Baltic and Thai, provided you own TrueType or Type1 fonts with the desired character set. UTF-8 support is also available.
For the UTF-8 support you have to use tFPDF which is based on FPDF. tFPDF accepts UTF-8 encoded text. Please read all this instructions and then download the ZIP file on the bottom from this site.
Convertation to UTF-8:
You do not need a convertation to UTF-8 if you use instructions above (from link) and load a UTF-8 string from a file like follows:
// this file file must be saved in UTF-8 before:
$str = file_get_contents('Text-saved-in-UTF-8.txt');
In other case:
You have to use mb_convert_encoding
and not iconv
.
For Serbian (Latin) this is either 'iso-8859-2'
or 'windows-1250'
. For Serbian (Cyrillic) this is 'iso-8859-5'
or 'windows-1251'
. These encodings will provide correct display of diacritic Latin characters such as žćđš
.
In yor case for:
$mystring = "Запослени у рачуноводству/сродном радном месту";
You have to write:
$str = mb_convert_encoding($mystring, 'UTF-8', 'iso-8859-5');
or
$str = mb_convert_encoding($mystring, 'UTF-8', 'windows-1251');
Your PHP file must be saved in iso-8859-5
or in windows-1251
before (but not in UTF-8).
And then you use this in tFPDF.
这篇关于FPDF中的塞尔维亚语字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!