Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

c++ - Opening fstream with file with Unicode file name under Windows using non-MSVC compiler

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...