php FPDF 和欧元符号的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19158756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problems with FPDF and Euro symbol
提问by Wayne Smallman
I've spent a couple of days sifting through various methods to encourage FPDF to render the Euro symbol, but none have succeeded. I have:
我花了几天时间筛选各种方法来鼓励 FPDF 渲染欧元符号,但没有一个成功。我有:
$currency = iconv("UTF-8", "ISO-8859-1//TRANSLIT", '');
Which results in:
结果是:
iconv() [function.iconv]: Detected an incomplete multibyte character in input string
iconv() [function.iconv]:在输入字符串中检测到不完整的多字节字符
I've tried a variety of encoding types, but to no avail.
我尝试了多种编码类型,但都无济于事。
回答by Gerard de Visser
You actually cangenerate a PDF with euro signs using FPDF with using euro ascii code: chr(128)
.
您实际上可以使用 FPDF 使用欧元 ascii 代码生成带有欧元符号的 PDF:chr(128)
.
It's good practice to make this a constant. At the top of your script, add:
将其设为常量是一种很好的做法。在脚本的顶部,添加:
define('EURO',chr(128));
Now you can use EURO
in your script to print the euro symbol.
For example:
现在您可以EURO
在脚本中使用来打印欧元符号。例如:
"Costs: ".EURO.100
Will output: Costs: 100
将输出: Costs: 100
Note: This will also work for other symbols with chr(ascii)
, where ascii
is the ascii code of the symbol. You can find an overview of ascii codes on this page: http://www.atwebresults.com/ascii-codes.php?type=2
注意:这也适用于其他带有 的符号chr(ascii)
,其中ascii
是符号的 ascii 代码。您可以在此页面上找到 ascii 代码的概述:http://www.atwebresults.com/ascii-codes.php?type=2
回答by Zaph
I've searched for ages, and nothing worked - until I used this: utf8_encode(chr(128))
我已经搜索了很长时间,但没有任何效果 - 直到我使用了这个:utf8_encode(chr(128))
回答by termigrator
the iconv
function worked for me
该iconv
功能对我有用
$text = "String with sign"
$pdfobj->Write(0,iconv('UTF-8', 'windows-1252', $text));
回答by Mahabubur Rahman masum
if You Want to show this line "£4.30" just follow bellow
如果您想显示此行“£4.30”,请按照以下步骤操作
$text = chr(163); $pound = $text."4.30 p m";
$text = chr(163); $英镑 = $text."4.30 p m";
Note: 163 = pound code;
注:163 = 英镑代码;