解决Windows下JpGraph中文乱码问题
2009-03-25 18:45
405 查看
解决Windows下JpGraph中文乱码问题
JpGraph中文乱码的问题很头痛,网上的教材大部分都没什么效果,历经一下午的测试,终于找到了一种方式,操作如下:
适用版本2.3,其他版本没有测试
1. 在jpgraph/src/jpgraph.php中最上面添加下面两行代码
define("CACHE_DIR", "./cache");
define("TTF_DIR", "c:/windows/fonts/");
上面两行可有有无,测试发现并没有带来什么样的改变.作用是:设置字体所在的目录和缓存所在的目录
查找$font_family=FF_FONT1替换为$font_family=FF_SIMSUN
2. 在jpgraph/src/jpgraph__ttf.inc.php中注释下面的代码
/*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::RaiseL(25006);
//('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);
}*/
3. 页面使用utf-8编码,设置图标标题中包含中文时,这样使用:
$graph->title->Set("我的一个测试Accumulated bar plots");
$graph->xaxis->title->Set("我的X-title");
$graph->yaxis->title->Set("你的Y-title");
$graph->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
JpGraph中文乱码的问题很头痛,网上的教材大部分都没什么效果,历经一下午的测试,终于找到了一种方式,操作如下:
适用版本2.3,其他版本没有测试
1. 在jpgraph/src/jpgraph.php中最上面添加下面两行代码
define("CACHE_DIR", "./cache");
define("TTF_DIR", "c:/windows/fonts/");
上面两行可有有无,测试发现并没有带来什么样的改变.作用是:设置字体所在的目录和缓存所在的目录
查找$font_family=FF_FONT1替换为$font_family=FF_SIMSUN
2. 在jpgraph/src/jpgraph__ttf.inc.php中注释下面的代码
/*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::RaiseL(25006);
//('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);
}*/
3. 页面使用utf-8编码,设置图标标题中包含中文时,这样使用:
$graph->title->Set("我的一个测试Accumulated bar plots");
$graph->xaxis->title->Set("我的X-title");
$graph->yaxis->title->Set("你的Y-title");
$graph->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
相关文章推荐
- JPgraph中文乱码问题解决
- JPgraph中文乱码问题解决 版本(jpgraph-3.0.7)
- 彻底解决windows英文版操作系统中文乱码问题
- Linux/Windows下MySQL5.6的修改字符集编码为UTF8(解决中文乱码问题)
- php jpgraph的中文乱码问题及解决方法
- 解决Python的print中文在windows命令行乱码问题
- 解决Gedit中文乱码问题:windows下正常转ubuntu文本乱码
- smb服务共享在windows下中文字符乱码问题的解决
- Windows平台下MySql5.6中文乱码问题解决
- 俺的gVim配置文件(解决了菜单栏,右键菜单和提示框中文乱码问题)(for windows,linux下应该也没问题)
- MySQL 5.7版本解决中文乱码问题(Windows)
- 解决Windows Git Bash中文乱码问题
- 如何解决JpGraph中文乱码的问题
- 解决Windows下Arm下Linux下Qt4程序的中文乱码问题
- 解决Windows Git Bash中文乱码问题
- 解决ubuntu打开windows下保存的txt文件中文乱码问题
- 解决matplotlib中文乱码问题(Windows)
- Linux_解决windows传送到linux下中文文件名及文件内容乱码问题
- git windows中文目录乱码问题解决
- Linux与Windows的文本文件格式转换,解决中文乱码和换行问题