c++ - How to open an std::fstream (ofstream or ifstream) with a unicode filename? -


You will not originally conceive in the form of something which is the use of the C ++ standard library for a Windows application It was difficult to open the tax file ... but it seems that from Unicode here I mean UTF-8, but I can get the UTF-16 or whatever is possible, pointing to an offstream example from a Unicode filename. Is there a preferred route here before I settle my own solution? Especially a cross-platform one?

The C ++ standard library is not unicode-aware char and Wchar_t does not require Unicode encoding.

On Windows, wchar_t is UTF-16, but there is no direct support for UTF-8 filaments in the standard library ( char datatype windows

With MSWC (and thus Microsoft STL), a constructor for Fistem is provided in which a const wchar_t * is the filename, from which You can create streams:

  wchar_t const name [] = l "filename.txt"; Std :: fstream file (name); However, this overload is not specified by the C ++ 11 standard (this guarantees the presence of  char  based version only) on the implementation of this optional STL. It also does not exist, such as GCC's LIBSTD + + minzwe (-v64), as version G ++ 4.8.x. 

Note that on Windows there is no char similar to UTF8, wchar_t can not be UTF 16 on the second OS. So overall, it is unlikely to be portable, according to the standard, opening a stream named a wchar_t file, and specifying a file name in char can be difficult Because the encoding used by Char is different between the OS I Es


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -