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

雨燕双飞 提交于 2019-11-28 11:10:00
Kornel Kisielewicz

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.

Currently there is no easy solution.

You need to create your own stream buffer that uses _wfopen under the hood. You can use for this for example boost::iostream

Convert the Unicode filename to a char* string using something like wcstombs() or WideCharToMultiByte() (which gives you far more control over the codepages involved).

Then use the converted filename to open the file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!