代码之家  ›  专栏  ›  技术社区  ›  Déjà vu

日语的PHP-gd文本显示很奇怪

  •  0
  • Déjà vu  · 技术社区  · 14 年前

    --enable-gd-jis-conv .

    $text = '夏の天気';
    $fontfile = '/usr/share/fonts/japanese/TrueType/sazanami-mincho.ttf';
    
    return imagettftext ($image, $size,  $angle,  $x,  $y,  $color, $fontfile, $text);
    

    但不一样 汉字

    可能是编码问题吗?

    3 回复  |  直到 12 年前
        1
  •  2
  •   The Mighty Rubber Duck    14 年前

    嗯,日语作为一种多字节编码语言有很多怪癖。 首先,确保您的服务器安装了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用于正则表达式的编码。

    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编码的数据馈送到函数。

        2
  •  1
  •   Déjà vu    14 年前

    我必须运行它才能工作

    $text = mb_convert_encoding('夏の天気', "SJIS", 'UTF-8');
    
        3
  •  0
  •   Nicholas Reed    13 年前
    imagettftext($this->im, 58, 0, 50, 100, $text_color, $font, mb_convert_encoding('佳人', 'UTF8', 'UTF-8'));