把T("123456中文 abcdefg  unicode \n")换成L("123456中文 abcdefg  unicode \n")试试;
see this article
http://www.codeproject.com/cpp/unicode.asp

解决方案 »

  1.   

    谢谢kingzai()提供的地址。这种加L的方式我也试过,也是不管用的。采用CFile来处理确实是可以的,但是我还是想知道 CStdioFile::WriteString如何才能改正这个bug呢。
      

  2.   

    我找到暂时的解决办法了CStdioFile 采用CFile::typeBinary方式打开文件
    m_pLogFile.WriteString(((unsigned short*))"123456中文 abcdefg  unicode \n");天,CStdioFile::WriteString 也太傻了吧。
    大家有没有更好的补丁?
      

  3.   

    msdn:CStdioFile have this property
    Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-mode CStdioFile object, the byte pair (0x0D, 0x0A) is sent to the file. When you read, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte
      

  4.   

    我想这是CStdioFile本来的设计,见MSDN:
    Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-mode CStdioFile object, the byte pair (0x0D, 0x0A) is sent to the file. When you read, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte.
      

  5.   


    CStdioFile::WriteString如何支持unicode编译中的中文?