乐哈哈旅游视频网:

CGI做中文处理时的问题!

#include   <stdio.h>  
  #include   <stdlib.h>  
   
  int   main(void)  
  {  
    unsigned   int   i=0,max=30;  
    char*   dest;  
    dest=(char*)malloc(max);  
    if(!dest)exit   (1);  
    printf("input   your   code   string:   ");  
    while((dest[i]=getchar())=='%')  
    {  
  if((dest[++i]   =getchar())   >=   'A')  
  dest[i]   =   ((dest[i]   &   0xdf)   -   'A')   +   10;  
  else  
  dest[i]   =   dest[i]   -   '0';  
  if((dest[++i]   =getchar())   >=   'A')  
  dest[i]   =   ((dest[i]   &   0xdf)   -   'A')   +   10;  
  else  
  dest[i]   =   dest[i]   -   '0';  
  dest[i/3]=dest[i]+dest[i-1]*16;  
  i++;  
  if(i==max)  
  {  
  max+=max;  
  dest=(char*)realloc(dest,max);  
  if(!dest)   exit(1);  
  }  
    }  
    dest[i/3]='\0';  
    printf("this   decode   string   is:%s\n",dest);  
    free(dest);  
    return   0;  
  }  
   
   
  献丑了:)  
   
  你输入一段%**%**   试试
posted on 2007-05-10 09:32  riky  阅读(548)  评论(0编辑  收藏  举报

乐哈哈旅游视频网: