How to write a unicode string to file

Discussion in 'C++' started by mimi, Mar 30, 2007.

  1. mimi

    mimi Guest

    #include <fstream>
    #include "stdio.h"

    int main()
    {
    // std::wofstream strm2("test.txt");
    // strm2 << L"ÎÒ°®±±¾©Ìì°²ÃÅ";

    FILE *hFile = fopen("test.txt", "wb+");
    wchar_t *buffer = L"ÎÒ°®±±¾©Ìì°²ÃÅ";
    fwrite (buffer , sizeof(buffer[0]) , 7 , hFile );
    fclose (hFile);

    return 0;
    }

    The program works. But how could i use wofstream in STL to write a
    unicode string to file? The code above which is commented does not
    work.
     
    mimi, Mar 30, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Knop
    Replies:
    1
    Views:
    320
  2. Stef Mientki
    Replies:
    0
    Views:
    288
    Stef Mientki
    Oct 16, 2009
  3. Benjamin Kaplan

    Re: how to write a unicode string to a file ?

    Benjamin Kaplan, Oct 16, 2009, in forum: Python
    Replies:
    1
    Views:
    606
    Paul Boddie
    Oct 16, 2009
  4. Donn
    Replies:
    2
    Views:
    340
  5. Stef Mientki
    Replies:
    0
    Views:
    747
    Stef Mientki
    Oct 17, 2009
Loading...

Share This Page