JPGraph處理有中文字符時都會轉成utf8編碼後顯示,我們只需注釋掉相關的代碼就可以了。
Dotproject苷特圖中文亂碼解決具體步驟如下:
1。修改jpgraph庫
打開dotproject \lib\jpgraph\jpgraph\src\jpgraph.php文件,找到下面代碼段
function Convert($aTxt,$aFF) {
if( LANGUAGE_CYRILLIC ) {
if( CYRILLIC_FROM_WINDOWS ) {
$aTxt = convert_cyr_string($aTxt, "w", "k");
}
$isostring = convert_cyr_string($aTxt, "k", "i");
$unistring = LanguageConv::iso2uni($isostring);
return $unistring;
}/* 注釋掉下面代碼段
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
}
elseif( $aFF === FF_CHINESE ) {
if( !function_exists('iconv') ) {
JpGraphError::Raise('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
}
return iconv('BIG5','UTF-8',$aTxt);
}注釋到此結束*/
else
return $aTxt;
}
2.修改dotproject中用到jpgraph的模塊
a. 改project模塊
打開dotproject\modules\projects\gantt.php文件,修改文件中下面的代碼
將所有
arialbd.ttf
用
simsum.ttc
替換
將所有
FF_ARIAL
用
FF_SIMSUN
替換
注釋掉下面的代碼
//if ( $locale_char_set=='utf-8' && function_exists("utf8_decode") ) {
//$name = utf8_decode($name);
//}
b.同理修改dotproject\modules\tasks\gantt.php文件