PHP加文字水印时报错 imagettftext() [function.imagettftext]: any2eucjp()

解决办法1:

由于GD库编译时添加了: --enable-gd-jis-conv    的支持(   GD: Enable JIS-mapped Japanese font ) , 在phpinfo()里也可以看到:JIS-mapped Japanese Font Support的支持为enable,需要重新编译PHP,在编译PHP时,去掉 --enable-gd-jis-conv即可

去掉编译选项“--enable-gd-jis-conv”

 

关闭GD库中 “JIS-mapped Japanese Font Support”

贴上官方的解释:

There is no fallback ot UTF-8. It accepts UTF-8 by default. The problem
about JIS is when you pass a non UTF-8 string, it can be seen as JIS
enconded string.

About the mbstring issues, I have no idea how it works and how it
affects the input parameters. It is something happening before we got
the hand in the gd function.

解决办法2:

mb_convert_encoding($markWords,"html-entities","UTF-8")

 

/**
* 将文本由UTF8编码转化为数字形式编码(HTML实体)
* @param $arr 该参数可以为数组或者string
* @author Steven lxq70361@qq.com
*/ 
function iconv_arr($arr){ 
if(is_array($arr)){
   foreach($arr as $k=>$v){
    $arr[$k] = iconv_arr($v);
   }
   
}else{
   $arr = mb_convert_encoding($arr, "html-entities","utf-8" );
}
return $arr;
}
?>

 

 

参考:

http://hi.baidu.com/xuguangzhi2003/item/9dd321e68460b8afc00d753b

http://blog.sina.com.cn/s/blog_6d677b680100tqb3.html

http://stackoverflow.com/questions/910793/detect-encoding-and-make-everything-utf-8

 

posted on 2012-09-03 21:12  胡博的博客  阅读(1117)  评论(0编辑  收藏  举报

导航