Results 1 to 4 of 4

Thread: Using basic_ofstream

  1. #1

    Thread Starter
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196

    Using basic_ofstream

    Is this right/OK/good/bad - whatever.

    Code:
    typedef basic_ofstream<TCHAR, char_traits<TCHAR> > tofstream;
    I am trying to create an output stream that takes characters of type TCHAR (as you can guess). The question is, does this actually do this?

    Thanks for your assistance.

    HD

  2. #2
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    Yes, this will work, but if you use a tofstreaf, and UNICODE is defined, the output will not be an ASCII text file. If you write wchar_t characters to a file, they will be written as two bytes.

  3. #3

    Thread Starter
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    Am I correct in assuming that as long as I use the equivalent input stream (tifstream) then this wont matter?

    My app needs to be localisable and therefore I required UNICODE support. TCHAR was suggested as the 'best' method of doing this.

    HD

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    This is possible.
    Here's a header file that does the same thing for all streams and for strings too.
    Attached Files Attached Files
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width