Jump to content
  • Advertisement
Sign in to follow this  
SlimTimmy

wifstream

This topic is 5105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What's the best way to read in unicode text files? I tried to use the wifstream class, but I did not work correctly. I create a unicode text file using notepad, then I loaded it into the MSVC Hexeditor. This looks like this: hexeditor.gif And that's the way I try to load it:
wifstream Stream("extensions.txt");
while(!Stream.eof())
{
  wstring String;
  getline(Stream,String);
  wcout << String <<endl;
}
How can I achieve this task? I think wifstream just reads byte after byte and then converts each single byte into a wchar_t.

Share this post


Link to post
Share on other sites
Advertisement
I believe the issue is with the codecvt used within the wstream classes for reading text in. Unfortunately, wstreams aren't required to read in 2 byte characters at a time and convert them to a single wide character as you are expecting. This makes them completely useless, at least for me. I believe the rationale is that they didn't want to require a certain byte representation to be used. I would just use binary file I/O to achieve the same thing.

Chalk this up as yet another reason I dislike the standard stream library.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!