我用“记事本”打开某个数据文件data.txt,其中中文"本地主机"显示正常。但我用ultraedit打开时显示为乱码。切换到HEX模式,显示为 -- E6 9C AC E5。但我用“记事本”实际输入"本地主机",生成新文件。然后用ultraedit打开,切换到HEX模式,显示为 -- B1 BE B5 D8。我想问的是data.txt"本地主机"编码-- E6 9C AC E5是什么编码?为什么用ultraedit打开是乱码,而用“记事本”打开显示正常?

解决方案 »

  1.   

    >>我试试了,没你说的情况呀
    你没有数据文件data.txt .:(数据文件data.txt好象并不是纯文本格式, 但不知道如何转换?
      

  2.   

    #include <stdio.h>
    #include <stdlib.h>int main()
    {
    FILE *in,*out;
    char infile[100],outfile[100];
    unsigned char ch,cha,chb;
    int i,j,k,size; printf("Enter the infile name: \n");
    scanf("%s",infile);
    printf("Enter the outfile name: \n");
    scanf("%s",outfile); if ((in=fopen(infile,"rb"))==NULL)
    {
    printf("Can not open infile!\n");
    exit(0);
    } if((out=fopen(outfile,"w"))==NULL)
    {
    printf("Can not open outfile!\n");
    exit(0);
    }

    size=0;
    while(!feof(in))
    {
    fgetc(in);
    size++;
    } printf("%d\n",size);
    j=1;
            k=0;
    rewind(in);
    while (k<size-1)
    {
    k++;
    ch=fgetc(in);
    cha=(unsigned char)0x80;
    for (i=0;i<8;i++)
    {
    chb=ch&cha; 
    chb=chb>>7;
    fprintf(out, "%d", chb );
    ch=ch<<1;
    }
            if (i==8)
    fputc(' ',out);
    if (j%4==0)
    fputc('\n',out);
    j++;
    } fclose(in);
    fclose(out);
    return 0;
    }/*二进制文件:010101010101010101010001
     *文本文件:0101 0101 0101 0101 
               0101 0001
    */
      

  3.   

    ????上面程序做什么的?我想问的是 -- E6 9C AC E5是什么编码格式?
    如何转化成 B1 BE B5 D8?
      

  4.   

    E6 9C AC E5是GBK的简体汉字
    B1 BE B5 D8是GBK的繁体汉字
    可用
    LCMapString(0x0804,LCMAP_TRADITIONAL_CHINESE, pszGbs, -1, pszGbt, len);

      

  5.   

    好像也不是,且我说反了
    B1 BE B5 D8是GBK的简体汉字
      

  6.   

    E6 9C AC 是UTF8编码,记事本能自动识别,E5是下一个汉字的编码,后面还有数据
             char str [ 256 ] = {0xE6,0x9c, 0xAc,  0xE5 ,0} ;  //一段UTF-8编码
             WCHAR* strA;
             int i= MultiByteToWideChar ( CP_UTF8 , 0 ,(char*) str ,-1 ,NULL,0);
             strA = new WCHAR[i];
             MultiByteToWideChar ( CP_UTF8 , 0 ,( char * ) str, -1, strA , i );
             i= WideCharToMultiByte(CP_ACP,0,strA,-1,NULL,0,NULL,NULL);
             char *strB=new char[i];
             WideCharToMultiByte (CP_ACP,0,strA,-1,strB,i,NULL,NULL);
    //strB即为所求
      

  7.   

    双字节字符的Leading Byte和当前OS使用的CodePage相关。