fp = fopen("gb.txt",2) for i=161 to 247 for j=161 to 254 =fwrite(fp,chr(i)+chr(j)) next =fwrite(fp,chr(13)+chr(10)) next =fwrite(fp,chr(26)) =fclose(fp)
转换的思路是这样的:(用foxpro书写) 首先将码表文件装入数组 fp = fopen("big5.txt") i = 0 do while feof(fp) i = i+1 dime dict[i] dict[i] = fgets(fp) enddo =fclose(fp) 其次将待转换的文本装入变量 create cursor temp (mm m) append blank append memo mm from textfilename text = mm 然后扫描文本,替换所有的GB编码 temp = "" i = 1 do while i < len(text) ch = substr(text,i,1) if isascii(ch) && 若是ASCII码 temp = temp+ch i = i+1 else ch1 = substr(text,i+1,1) big5 = substr(dict[asc(ch)-161+1],(asc(ch1)-161)*2+1,2) temp = temp+big5 i = i+2 endif enddo 最后将在temp中得到转换后的文本