[ACCEPTED]-How to use std::ifstream to read in a binary file with a wide string path-fstream

Accepted answer
Score: 13

The current C++ standard doesn't provide 10 wide char paths. Even the wchar_t version 9 receives a regular const char* filename. You 8 already used a compiler extension, so continue 7 using this extension with a normal ifstream:

std::wstring wPath(L"blah");
std::ifstream ifs(wPath.c_str(), std::ios::in | std::ios::binary)

EDIT: consider 6 using utf-8 strings instead of wide strings and use Boost.Nowide (not yet 5 in boost) to open files.

EDIT: Boost.Nowide was 4 accepted in boost. Also Windows 10 added support for UTF-8 in its 3 narrow-string API, which can be enabled 2 through a manifest. This makes all the wide-char 1 interfaces pretty much unportable and redundant.

More Related questions