In a C ++ project, I want to open file ( fstream::open()) (which seems to be a serious problem). The windows build of my program fails.
fstream::open()
File "Γ€" (UTF-8 0xC3 0xA4)
std::string s = ...; //Convert s std::fstream f; f.open(s.c_str(), std::ios::binary | std::ios::in); //Works (f.is_open() == true) f.close(); f.open(s.c_str(), std::ios::binary | std::ios::in | std::ios::out); //Doesn't work
The string sis encoded in UTF-8 encoding, but then converted from UTF-8 to Latin1 (0xE4). I use Qt, therefore QString::fromUtf8(s.c_str()).toLocal8Bit().constData().
s
QString::fromUtf8(s.c_str()).toLocal8Bit().constData()
Why can I open a file for reading, but not for writing?
File and (UTF-8 0xD0 0xB8)
The same code does not work at all.
This symbol does not seem to fit in the encoding of Windows-1252. How can I open such fstream (I do not use MSVC, therefore nofstream::open(const wchar_t*, ios_base::openmode) )?
fstream::open(const wchar_t*, ios_base::openmode)
API (, std:: fstream) Windows, , , " ANSI" (CP_ACP).
, , API Windows. Microsoft CP_ACP CP_UTF8, Microsoft CRT ++.
( Windows , "" , , , ASCII, API. , .)
Microsoft STL (), Unicode UTF-16.
UTF-16 std:: wstring fstream:: open(). fstream.
, unicode : http://utf8everywhere.org/