Read/Write file with unicode file name with plain C++/Boost

前端 未结 4 1764
Happy的楠姐
Happy的楠姐 2021-02-20 12:56

I want to read / write a file with a unicode file name using boost filesystem, boost locale on Windows (mingw) (should be platform independent at the end).

This is my co

4条回答
  •  忘掉有多难
    2021-02-20 13:52

    I don't know how the answer here got accepted, since OP does fs::path::imbue(std::locale()); precisely not to give a damn about OS's codepage, std::wstring and what not. Otherwise yeah, he'd just use plain old iconv, Winapi calls or other things suggested in the accepted answer. But that is not the point of using boost::locale here.

    The real answer why this doesn't work, even though OP does imbue() current locale like instructed in the Boost's documentation (see "Default Encoding under Microsoft Windows"), is because of boost (or mingw) bugs that go unresolved for at least a couple of years as of March 2015.

    • Issue #9968
    • Issue #9450
    • Issue #5769

    Unfortunately, mingw users seem to be left out in the cold.

    Now, what boost developers should do in order to cover for these bugs is a whole different matter. It might turn out they need to implement precisely what Dan has stated.

提交回复
热议问题