最后,我不得不用--enable-gd-jis-conv重新编译PHP。然而,在日语中,文本显示是错误的。
$text = '夏の天気';
$fontfile = '/usr/share/fonts/japanese/TrueType/sazanami-mincho.ttf';
return imagettftext ($image, $size, $angle, $x, $y, $color, $fontfile, $text);但是不同的汉字(日语字符)却被显示出来(非常不同,看起来像中文)。
会不会是编码问题?
在RHEL 5.4上使用PHP 5.3.3。
发布于 2010-09-13 03:39:11
我不得不运行这个才能让它开始工作
$text = mb_convert_encoding('夏の天気', "SJIS", 'UTF-8');发布于 2010-09-13 03:28:33
嗯,日语作为一种多字节编码语言,有相当多的古怪之处。首先,确保您的服务器安装了mbstring模块。
其次,为了减少中途损坏的可能性,尽量保持站点/项目中所有编码的一致性:理想情况下,站点视图和源文件应该使用相同的编码方式编写。
针对您的问题,您可能需要尝试使用以下函数:
mb_http_input http://www.php.net/manual/en/function.mb-http-input.php
这将确保您的HTTP输入是正确的编码(即。表格资料)。
mb_ internal_ encoding http://www.php.net/manual/en/function.mb-internal-encoding.php
设置PHP使用的内部编码。
mb_regex_encoding http://www.php.net/manual/en/function.mb-regex-encoding.php
设置PHP用于regexes的编码。
mb_convert_encoding http://www.php.net/manual/en/function.mb-convert-encoding.php
用于字符串转换。
mb_convert_variables http://www.php.net/manual/en/function.mb-convert-variables.php
转换整批字符串/数组的编码。
编辑:此外,从模块的名称来看,您可能需要尝试将JIS编码的数据添加到函数中。
发布于 2011-07-31 09:40:22
imagettftext($this->im, 58, 0, 50, 100, $text_color, $font, mb_convert_encoding('佳人', 'UTF8', 'UTF-8'));这对我有用。似乎可以跨越几个不同的日文字体。
https://stackoverflow.com/questions/3697626
复制相似问题