Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I need to open a file as std::fstream (or actually any other std::ostream) when file name is "Unicode" file name.
Under MSVC I have
non-standard
extension
std::fstream::open(wchar_t const *,...)
? What can I do with other compilers like GCC (most important) and probably Borland compiler.
I know that CRTL provides
_wfopen
but it gives C
FILE *
interface instead of io-streams, maybe there is a non-standard way to create io-stream from
FILE *
? Is there any
boost::ifstream
with MSVC like extension for Windows?
–
–
–
Unfortunately, there's no standard way to do that, although C++0x (1x?) promises to do that. Until then, you properly assumed that a solution can be found in Boost, however, the library you're searching for is
Boost.Filesystem
.
Boost.Filesystem internally uses wide strings by default for its universal path system, so there are no unicode problems in this regard.
–
–
–
–
–
–
Convert the Unicode filename to a
char*
string using something like
wcstombs()
or
WideCharToMultiByte()
(which gives you far more control over the codepages involved).
Then use the converted filename to open the file.
–
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.