How to set file encoding format to UTF8 in C++

后端 未结 4 968
慢半拍i
慢半拍i 2021-01-13 03:59

A requirement for my software is that the encoding of a file which contains exported data shall be UTF8. But when I write the data to the file the encoding is always ANSI. (

4条回答
  •  清歌不尽
    2021-01-13 04:14

    On Windows in VC++2010 it is possible (not yet implemented in GCC, as far as i know) using localization facet std::codecvt_utf8_utf16 (i.e. in C++11). The sample code from cppreference.com has all basic information you would need to read/write UTF-8 file.

    std::wstring wFromFile = _T("

提交回复
热议问题