Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to write a unicode string to a text file

how to write a unicode string to a text file

Scheduled Pinned Locked Moved C / C++ / MFC
iostutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ChrisLang
    wrote on last edited by
    #1

    I want to write a CStringW string to a wfstream but it doesn't seem to work. Does anyone know how to do this? my sipet is: CStringW sRus(_T("ершы шы ф еуые")); wfstream outFile; outFile.open("C:\\Junk.txt",ios_base::out); outFile << sRus << '\n'; outFile.close(); Chris

    N T K 3 Replies Last reply
    0
    • C ChrisLang

      I want to write a CStringW string to a wfstream but it doesn't seem to work. Does anyone know how to do this? my sipet is: CStringW sRus(_T("ершы шы ф еуые")); wfstream outFile; outFile.open("C:\\Junk.txt",ios_base::out); outFile << sRus << '\n'; outFile.close(); Chris

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      I haven't used wfstream before, but this article may be useful :- http://www.codeproject.com/file/stdiofileex.asp[^]

      1 Reply Last reply
      0
      • C ChrisLang

        I want to write a CStringW string to a wfstream but it doesn't seem to work. Does anyone know how to do this? my sipet is: CStringW sRus(_T("ершы шы ф еуые")); wfstream outFile; outFile.open("C:\\Junk.txt",ios_base::out); outFile << sRus << '\n'; outFile.close(); Chris

        T Offline
        T Offline
        Taka Muraoka
        wrote on last edited by
        #3

        ChrisLang wrote:

        I want to write a CStringW string to a wfstream but it doesn't seem to work

        The reason why is explained here[^].


        The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.

        1 Reply Last reply
        0
        • C ChrisLang

          I want to write a CStringW string to a wfstream but it doesn't seem to work. Does anyone know how to do this? my sipet is: CStringW sRus(_T("ершы шы ф еуые")); wfstream outFile; outFile.open("C:\\Junk.txt",ios_base::out); outFile << sRus << '\n'; outFile.close(); Chris

          K Offline
          K Offline
          krmed
          wrote on last edited by
          #4

          You need to open the file in binary mode:

          outFile.open("C:\\Junk.txt",ios_base::out | ios_base::binary);

          Hope that helps. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups