CStdioFile csf(sPath,CFile::modeRead | CFile::typeText);
csf.ReadString(strTemp);
读出来的strTemp里的中文是乱码,英文和数字是正确的,
怎么纠正呀!解决后立刻给分。

解决方案 »

  1.   

    CString m_disp;
    CStdioFile csf(sPath,CFile::modeRead | CFile::typeText);
    csf.Read(m_disp.GetBufferSetLength(myfile.GetLength()),myfile.GetLength());
      

  2.   

    可是myfile又哪来的呢,我要一行一行读的呀。
    m_disp.GetBufferSetLength()的目的是为了什么呢。
      

  3.   

    应该是汉字编码的问题,你把那个文件采用ANSI格式保存试试,或者采用API转换,假如你使用ATL的话,直接使用_bstr_t就可以了
      

  4.   

    myfile改为csf如果你想一行一行读,用如下代码(包括中文):
     FILE *stream;
      char line[255];  
      if( (stream = fopen( "f:\\aa.txt", "r" )) != NULL )      
      {      
      while (!feof(stream))   
      {    
      char *ch = fgets( line, 1024, stream );//读一行
                               MessageBox(line);
      if (ch == NULL) break;
      if(j>10) break;
      
      if (ch[0] == 10)    
      continue;
      
      }
      
      fclose( stream ); 
      
      }