c++ - Using ifstream when filename contains wide characters -



c++ - Using ifstream when filename contains wide characters -

using c++builder xe5 (bcc32) in windows 7.

i trying open file filename contains wide character. actual filename i'm testing c:\bΛx\foo.txt. non-ascii character there u+039b .

i have filename stored correctly in std::wstring. however, trying:

std::ifstream f( filename.c_str() );

fails open file.

of course, in standard c++ fopen takes char *. however, dinkumware c++ rtl implementation has overload accepting wchar_t *. unfortunately implementation of overload in ...\embarcadero\rad studio\12.0\source\cpprtl\source\dinkumware\source\fiopen.cpp not phone call _wfopen. instead uses wcstombs convert string utf-8 , calls fopen.

checking source fopen, calls narrow version of underlying function ___topen passes utf-8 string createfile.

when inspect effort open file using sysinternals process monitor, shows did effort open file utf-8 file string, , operating scheme rejected result name collision.

if open file using _wfopen( filename.c_str(), l"r" ) , can read file using c i/o functions, can't utilize c++ iostreams of course.

is there way utilize std::ifstream open file u+039b or other such characters in filename?

note using std::wifstream doesn't work either (it still tries open utf-8 version of filename).

if open file using _wfopen( filename.c_str(), l"r" ) , can read file using c i/o functions, can't utilize c++ iostreams of course.

i don't see "of course". problem reduced making iostreams streambuf file*. howard hinnant answered here there's no method provided standard, implementing streambuf-derived class on top of file* pretty straightforward. mentions code feels starting point.

note makes sense text file. iostreams , binary files not along; there's character encoding layer , ios_base::binary not turn off.

c++ windows unicode ifstream c++builder-xe5

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -