VC7平台下如下代码:CStdioFile clsFile;if(!clsFile.Open(TEXT("C:\\1.csv"), CFile::modeCreate|CFile::modeWrite|CFile::typeText))
{
     MessageBox(TEXT("文件创建失败!"),TEXT("提示"));
     return;
}TCHAR szTitle[] = TEXT("ID,姓名");
TCHAR szContent[] = TEXT("adasda,asdasdasd");clsFile.WriteString(szTitle);
clsFile.WriteString(szContent);clsFile.Close();
如果用Debug编译,szTitle、szContent都写入了CSV文件中但是,如果用Debug Unicode编译,则szTitle中的中文写不进文件中。哪位知道怎么解决?

解决方案 »

  1.   

    http://www.codeproject.com/cpp/unicode.asp?target=writestring
      

  2.   

    具体情况不太清楚, 不过我看MSDN上是这么说滴:
    Re: 
        Writes data from a buffer to the file associated with the CStdioFile object. The terminating null character (‘\0’) is not written to the file. Any newline character in lpsz is written to the file as a carriage return–linefeed pair. 
    好像得有个 结束符号? 
    还有, 打开模式得typeText, 应该用二进制方式吧.
    呵呵, 没有写过测试程序, 我的猜测罢了.