wifstream only accepts const char*?

Apparently ifstream (and children) only accept const char* as a filename.
What am I supposed to do in this case if I need Unicode support (on Windows)?
I don't mind not supporting it on Linux-based systems as it's not like Unicode paths popup very often there.

Is the argument just a multibyte string, or is it truly ASCII-only?
If so, can I simply use wcstombs?
Nevermind, I read up on UTF8 Everywhere and am pretty convinced this is what I'll do.
However, this issue remains unsolved for people that disagree.
Last edited on
On linux const char* or std::string usually handles unicode just fine because it uses UTF-8.

Not sure what the best way to handle this is on Windows but I've noticed that since C++17 you can open an ifstream or wifstream from a std::filesystem::path. I haven't played around with it yet so I'm not sure but maybe this can be used to handle file paths in a more cross-platform manner.
Midnightas wrote:
What am I supposed to do in this case if I need Unicode support (on Windows)?

On Windows, ifstream constructors non-portably accept wide strings, which they expect to contain UTF-16le. The portable solution comes with C++17's filesystem API.

I read up on UTF8 Everywhere

that is indeed the way to go.
Last edited on
Topic archived. No new replies allowed.