数组 $txt[$y] 丢失特殊字符
Array $txt[$y] loses special characters
我必须将下面的 $txt[$y]
编码为 utf-8 或 ISO-8859-1。我使用带有特殊字母的字体扩展的 tFPDF。现在字符串在单元格中正确显示,但是当我使用 ś、й、é 等特殊字母时,我只能看到问号:
function magia($txt='', $border=0, $ln=0, $align='C', $fill=false, $link='', $scale=false, $force=true){
$str_width = $this->GetStringWidth($txt);
$len = strlen($txt);
for ($y = 0; $y < $len; $y++){
$this->Cell(6,6,$txt[$y],0,0,'C');
}
}
使用mb_
函数。 PHP 仍然不是完全 UTF-8 友好的。
$x[0]
对某些特殊字符无效。使用例如 mb_substr()
函数来获取字符。有很多 mb_
字符串函数等同于可以对选定字符集进行操作的普通函数。
mb_substr($str,1,1)
将获取第二个字母。
http://php.net/manual/en/function.mb-substr.php
+1
对于 magia
:D
我必须将下面的 $txt[$y]
编码为 utf-8 或 ISO-8859-1。我使用带有特殊字母的字体扩展的 tFPDF。现在字符串在单元格中正确显示,但是当我使用 ś、й、é 等特殊字母时,我只能看到问号:
function magia($txt='', $border=0, $ln=0, $align='C', $fill=false, $link='', $scale=false, $force=true){
$str_width = $this->GetStringWidth($txt);
$len = strlen($txt);
for ($y = 0; $y < $len; $y++){
$this->Cell(6,6,$txt[$y],0,0,'C');
}
}
使用mb_
函数。 PHP 仍然不是完全 UTF-8 友好的。
$x[0]
对某些特殊字符无效。使用例如 mb_substr()
函数来获取字符。有很多 mb_
字符串函数等同于可以对选定字符集进行操作的普通函数。
mb_substr($str,1,1)
将获取第二个字母。
http://php.net/manual/en/function.mb-substr.php
+1
对于 magia
:D