imagettftext ===>> 点击查看函数说明
1.重新编译去掉 enable-gd-jis-conv 选项
2.imagettftext()也接受另外一种字符表示方法,类似HTML的字符参考。说“类似”是因为GD只接受数字参考,所以内部函数 (如 mb_convert_encoding) 转出来的没用。 以下的函数可以将UTF-8转换成字符参考:
function to_entities($string){
$len = strlen($string);
$buf = "";
for($i = 0; $i < $len; $i++){
if (ord($string[$i]) <= 127){
$buf .= $string[$i];
} else if (ord ($string[$i]) <192){
//unexpected 2nd, 3rd or 4th byte
$buf .= "�";
} else if (ord ($string[$i]) <224){
//first byte of 2-byte seq
$buf .= sprintf("&#%d;",
((ord($string[$i + 0]) & 31) << 6) +
(ord($string[$i + 1]) & 63)
);
$i += 1;
} else if (ord ($string[$i]) <240){
//first byte of 3-byte seq
$buf .= sprintf("&#%d;",
((ord($string[$i + 0]) & 15) << 12) +
((ord($string[$i + 1]) & 63) << 6) +
(ord($string[$i + 2]) & 63)
);
$i += 2;
} else {
//first byte of 4-byte seq
$buf .= sprintf("&#%d;",
((ord($string[$i + 0]) & 7) << 18) +
((ord($string[$i + 1]) & 63) << 12) +
((ord($string[$i + 2]) & 63) << 6) +
(ord($string[$i + 3]) & 63)
);
$i += 3;
}
}
return $buf;
}
imagettftext($im, 11, 0, 5, 11, $black, $font, to_entities($text));
未经允许不得转载:开心乐窝-乐在其中 » imagettftext因为enable-gd-jis-conv导致乱码的解决方法


