⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bcjq076.txt

📁 c++ builder 的一些txt文档
💻 TXT
字号:

C++ Builder开发者:程序员之家
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
 
  
  
    
      
        
          
            首页   
              | 控件天堂 | 控件使用                    
              | 编程技巧                     
              |  源代码 |  编程工具 |         
               系统补丁 |  电子书籍 | 技术论坛                     
              |  相关链接                  
                            
                          
                        
                      
                      
                        
                          
                            
                              
                            
                  
       if (ad==1) {document.write(''+'');}                
       if (ad==2) {document.write(''+'');}                
       if (ad==3) {document.write(''+'');}                
                               
                            
                         
                                     
                         
                       
                     
                   
                   
                     
                       
                         
                           
                        
                      
var marqueecontents=''+scroll_text+''            
if (document.all)            
document.write(''+marqueecontents+'')            
function regenerate(){            
window.location.reload()            
}            
function regenerate2(){            
if (document.layers){            
setTimeout("window.onresize=regenerate",450)            
intializemarquee()            
}            
}            
function intializemarquee(){            
document.cmarquee01.document.cmarquee02.document.write(marqueecontents)            
document.cmarquee01.document.cmarquee02.document.close()            
thelength=document.cmarquee01.document.cmarquee02.document.height            
scrollit()            
}            
function scrollit(){            
if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){            
document.cmarquee01.document.cmarquee02.top-=speed            
setTimeout("scrollit()",100)            
}            
else{            
document.cmarquee01.document.cmarquee02.top=marqueeheight            
scrollit()            
}            
}            
window.onload=regenerate2            
                        
                          
                        
                      
                    
                  
                  
                    
                      
                        
                          
                            
                              
                                
                  当前位置
     
     
                    编程技巧             
                             
                           
                         
                         
                         
                           
                             
                               
                    BIG5到GB的转换技术         
                           
                     
                       
                         
                           
                          中文因为数量太多,所以与英文用ASCII码一个字节表示不同,它使用两个字节来表示。通过计算这两个字节,我们可以得到其表示的汉字在中文字库中的位置。读取该位置的若干字节,以获得表示这个汉字的点阵信息。有了这些信息,就可以分别在DOS或WINDOWS中显示该汉字。事实上,在文本文件中保存的就是每个汉字对应的两个字节编码,而显示问题由中文操作系统自动解决。
  汉字编码并不统一,我们使用的是GB码,而台湾地区使用的是BIG5码。BIG5码文件中保存的是汉字相应的BIG5编码,GB码文件中保存的是汉字相应的GB编码(这也就是“乱码现象”的来由)。所以转换工作的关键是有一个记录每个BIG5编码对应GB编码的码表文件。
      第一步 制作码表文件
  
  BIG5码编码规则是这样的:每个汉字由两个字节构成,第一个字节的范围从0X81-0XFE,共126种。第二个字节的范围分别为0X40-0X7E,0XA1-0XFE,共157种。也就是说,利用这两个字节共可定义出 126 * 157=19782种汉字。这些汉字的一部分是我们常用到的,如一、丁,这些字我们称为常用字,其BIG5码的范围为0XA440-0XC671,共5401个。较不常用的字,如滥、调,我们称为次常用字,范围为 0XC940-0XF9FE,共7652个,剩下的便是一些特殊字符。
  
  制作码表文件的原理是这样的:首先将所有的BIG5编码写入一个文件,然后,使用具有BIG5码到GB码转换功能的软件,如地球村、东方快车、四通利方,将文件转换为GB码文件,即得到码表文件。
  
  下面的源程序将所有可能的BIG5编码(0XA100-0XFEFF)写入文件“Table.TXT”。
  
      //TURBO C++ 3.0
  
      #include <Stdio.h>
  
      #include <stdlib.h>
  
      void main(){
  
      FILE * codefile;
  
      int i,j,k;
  
      codefile=fopen("table.txt","w+b");
  
      for (i=0xa1;i<=0xfe;I++){
  
      for(j=0x00;j<=0xff;j++){
  
      fwrite(& i,1,1,codefile);
  
      fwrite(& j,1,1,codefile);}
  
      }
  
      fclose(codefile);
  
      return;
  
      }
  
  运行地球村、东方快车或四通利方,将“Table.txt”从BIG5码转换为GB码,即获得码表文件。
  
      第二步 转换
  
  下面的源程序,将BIG5码文件转换为GB码文件。
  
      //TURBO C++3.0
  
      #include <stdio.h>
  
      #include <stdlib.h>
  
      void main(){
  
      int que, wei;
  
      FILE * sourcefile;
  
      FILE * tabfile;
  
      FILE * destfile;
  
      sourcefile = fopen("big.txt', "r+b");
  
      //BIG5 码文件
  
      tabfile = fopen("table.txt", 'r+b");
  
      //码表文件
  
      destfile = fopen("gb.txt","w+b");
  
      //转换生成的GB码文件
  
      while (!feof(sourcefile)){
  
      fread(& que,1,1,sourcefile);
  
      if (feof(sourcefile)){
  
      break; }
  
      if (que> =0xa1 && que <=0xfe)
  
      //叛断是否汉字(BIG5编码)
  
      {fread(& wei,1,1,sourcefile);
  
      if (wei<0xa1) wei = wei - 0x40;
  
      if (wei>=0xa1) wei = wei - 0xa1 + 0x7e - 0x40 + 1;
  
      fseek(tabfile, 2 * ((que -0xa1) * (0xfe - 0xa1 + 1 + 0x7e - 0x40 + 1 ) + wei), SEEK_SET);
  
      fread(& que,1,1,tabfile);
  
      fread(& wei,1,1,tabfile);
  
      fwrite(& que,1,1,destfile);
  
      fwrite(& wei,1,1,destfile);
  
      }
  
      else
  
      fwrite(& que,1,1,destfile); //处理英文
  
      }
  
      fclose(sourcefile);
  
      fclose(tabfile);
  
      fclose(destfile);
  
      return;
  
      }
  
  以上程序在Win95/97,TC3.0 通过。稍加修改,也可用于VC或VB程序中。用同样的方法,我们也可以将GB码转换为BIG5码。      
                              
                            
                                
                        
                              
                                
                              
                  if (ad==1) {document.write(''+'');}              
                  if (ad==2) {document.write(''+'');}              
                  if (ad==3) {document.write(''+'');}              
                                                
                              
                            
                          
                        
                   
                    
                      
                        
                      
                      
                          
                      
                    
                       
                     
                   
                 
               
               
                 
                   
                     
                       
            C++ Builder开发者®            
              2000年06月01日 站长:唐朝            
                      
                    
                  
                
                
                  
                
              
              
            
            
            
            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -