免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1821 | 回复: 0
打印 上一主题 下一主题

求助:能帮我写段代码吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-02-20 08:20 |只看该作者 |倒序浏览
webalizer 中graphs.c因该是用C编的吧,我对C一窍不通...
  1. void init_graph(char *title, int xsize, int ysize)
  2. {
  3.    int i;

  4.    im = gdImageCreate(xsize,ysize);

  5.    /* allocate color maps, background color first (grey) */
  6.    grey    = gdImageColorAllocate(im, 192, 192, 192);
  7.    dkgrey  = gdImageColorAllocate(im, 128, 128, 128);
  8.    black   = gdImageColorAllocate(im, 0, 0, 0);
  9.    white   = gdImageColorAllocate(im, 255, 255, 255);
  10.    green   = gdImageColorAllocate(im, 0, 128, 92);
  11.    orange  = gdImageColorAllocate(im, 255, 128, 0);
  12.    blue    = gdImageColorAllocate(im, 0, 0, 255);
  13.    red     = gdImageColorAllocate(im, 255, 0, 0);
  14.    cyan    = gdImageColorAllocate(im, 0, 192, 255);
  15.    yellow  = gdImageColorAllocate(im, 255, 255, 0);

  16.    /* make borders */

  17.    for (i=0; i<5 ;i++)          /* do shadow effect */
  18.    {
  19.       gdImageLine(im, i, i, xsize-i, i, white);
  20.       gdImageLine(im, i, i, i, ysize-i, white);
  21.       gdImageLine(im, i, ysize-i-1, xsize-i-1, ysize-i-1, dkgrey);
  22.       gdImageLine(im, xsize-i-1, i, xsize-i-1, ysize-i-1, dkgrey);
  23.    }

  24.    gdImageRectangle(im, 20, 25, xsize-21, ysize-21, black);
  25.    gdImageRectangle(im, 19, 24, xsize-22, ysize-22, white);
  26.    gdImageRectangle(im, 0, 0, xsize-1, ysize-1, black);
  27.    gdImageStringFT(im,0,blue,myfont,10,0.0,20,8,title);    /*
  28.    return;
  29. }
复制代码

想把char *title由GB2312编码变成UTF-8编码怎么做?
gdImageStringFT(im,0,blue,myfont,10,0.0,20,8,"汉字";生成的图片中汉字是乱码 ,
gdImageStringFT(im,0,blue,myfont,10,0.0,20,8,"锘挎眽瀛";生成的图片汉字正常了.......
http://xcin.linux.org.tw/i18n/pc2000/p4/node2.html
http://cosoft.org.cn/snippet/detail.php?type=snippet&id=4571
我觉得
#include <iconv.h>;
...
fd = iconv_open("UTF-8", "936";
trans_size = iconv(fd, &fromstr_p, &fromsize, &tostr_p, &tosize);
iconv_close(fd);
.....
就是我要用的......
gdImageStringFT字符肯定要UTF-8才能正确显示汉字.
谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP