Read unicode text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mariii
    New Member
    • May 2007
    • 8

    Read unicode text file

    Hello All!

    I have a problem with reading unicode txt file from VC++ project. I despaired already. :( May be you could help me?

    Thank a lot in advance,
    Marina
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    Could you please elaborate on the problem.....
    Specifically: Do you just need to parse into ascii like characters, or do you specifically need to be able to read/display more obscure characters

    Comment

    • Mariii
      New Member
      • May 2007
      • 8

      #3
      Originally posted by DeMan
      Could you please elaborate on the problem.....
      Specifically: Do you just need to parse into ascii like characters, or do you specifically need to be able to read/display more obscure characters
      I need to read the file till the end, file looks like:
      Code:
      text1;something;something
      text2;something;something
      text3;something;something
      text4;something;something
      And I need to parse every row and to form the vector based on these data.

      Comment

      • Mariii
        New Member
        • May 2007
        • 8

        #4
        I found this. But I cann't believe, that it is the only way to read this bloody unicode text file! It should be other way!

        Comment

        • DeMan
          Top Contributor
          • Nov 2006
          • 1799

          #5
          Ultimately a file is just a collection of bits so how you want to read it depends depends on what you want to do with it. If you know that you will be reading converted ascii characters only, then you simply read characters ignoring NULL. If you actually want to process information as Unicode the story gets a little harder.

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            Have you tried using a wifstream object?

            Comment

            • Mariii
              New Member
              • May 2007
              • 8

              #7
              Originally posted by DeMan
              Ultimately a file is just a collection of bits so how you want to read it depends depends on what you want to do with it. If you know that you will be reading converted ascii characters only, then you simply read characters ignoring NULL. If you actually want to process information as Unicode the story gets a little harder.
              I need to process reading information, but it's not necessary to do it in unicode. How can I read ignoring NULL? When I try to read with CStdioFile I can't get even the whole row. Should I do it with istream operators?

              Comment

              • Mariii
                New Member
                • May 2007
                • 8

                #8
                Originally posted by weaknessforcats
                Have you tried using a wifstream object?
                Not yet, but I try to try it.

                Comment

                • Mariii
                  New Member
                  • May 2007
                  • 8

                  #9
                  Originally posted by weaknessforcats
                  Have you tried using a wifstream object?
                  I still read only nonsense symbols with it:

                  Code:
                  wchar_t wcht[1024];
                  char *cfn = "C:\\test.csv";
                  wifstream wifstrm(cfn, ios_base::in);
                  wifstrm.getline(wcht,1024,'\n');

                  Comment

                  Working...