【发布时间】:2020-01-05 08:31:03
【问题描述】:
要将特殊字符打印到 FPDF,我可以使用:
$this->Cell($w2, 15, iconv('UTF-8', 'windows-1252', $text));
或
$this->Cell($w2, 15, utf8_decode($text));
但这些都不适用于strtoupper。示例:
$this->Cell($w2, 15, strtoupper(iconv('UTF-8', 'windows-1252', $text)));
$this->Cell($w2, 15, strtoupper(utf8_decode($text)));
$this->Cell($w2, 15, iconv('UTF-8', 'windows-1252', strtoupper($text)));
$this->Cell($w2, 15, utf8_decode(strtoupper($text)));
给定:
$text = "Conformità";
所有这些都返回:
确认
代替:
符合标准
更新
此处或其他答案中提出的解决方案不起作用:
mb_strtoupper($text);
mb_strtoupper($text, 'UTF-8');
打印
符合要求
【问题讨论】:
-
@Jeto,正如评论中所说,链接答案提供的解决方案不起作用。
-
好像do work?
-
它可能不起作用,因为您的字符集已损坏 - 它需要在整个应用程序中设置,最好是相同的,而无需在字符集之间切换。如果你可以在任何地方使用它,我推荐 UTF8。阅读stackoverflow.com/questions/279170/utf-8-all-the-way-through
-
@Mark 我投票决定重新开放。
-
@Mark 我已经在本地测试了this,它输出了正确的结果。你可以试试看。
标签: php utf-8 character-encoding fpdf