StdioFile类读取中文乱码的问题

        CStdioFile f1;
	if( !f1.Open( filePath, CFile::modeReadWrite) ) {
			#ifdef _DEBUG
					afxDump << "Unable to open file" << "\n";
			#endif
					exit( 1 );
	}

	//设定中文环境 
	char* old_locale=_strdup( setlocale(LC_CTYPE,NULL) ); 
	setlocale( LC_CTYPE,"chs"); 
	
	//-----------------读取内容-------------------//
	CString lineText;	
	while (f1.ReadString(lineText))
	{
		m_lstbFileContent.AddString(lineText);
	}
	//------------------读取内容----------------//

	//还原locale的设置
	setlocale( LC_CTYPE, old_locale ); 
	free( old_locale );

  

posted on 2011-11-10 17:46  LateStop  阅读(936)  评论(0)    收藏  举报

导航