• Advertisement
Sign in to follow this  

Passing as std::basic_istream TCHAR

This topic is 3843 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

I need to call a function with the following prototype: XmlDocument( std::basic_istream< TCHAR > & stream ) I'm trying to open a file and pass the stream in, but I can't figure out how to convert an istream into the right form.

Share this post


Link to post
Share on other sites
Advertisement

std::basic_ifstream<TCHAR> ifs("file.xml");

XmlDocument(ifs);

Share this post


Link to post
Share on other sites
What IDE and compiler? In case you didn't know TCHAR just takes the form of whatever character type is set as the default (usually char for ASCII and wchar_t for Unicode) so if you just set the default character set to be ASCII it should work since std::istream really is std::basic_istream<char>. If you actually care for Unicode characters then you shouldn't use std::istream in the first place, but rather std::basic_istream< TCHAR > if you want to be able to switch or std::wistream if you only care about Unicode characters.

In Visual Studio you change the character set by right-clicking on your project, going to properties and in the General tab you change Character Set from Use Unicode Character Set to Use Multi-byte Character Set.

Share this post


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

  • Advertisement