Open std::fstream in a unicode-safe manner.

This commit is contained in:
Jordan Woyak
2013-02-28 19:33:39 -06:00
parent 95558cdc69
commit dea1e2827d
19 changed files with 57 additions and 25 deletions

View File

@ -25,6 +25,7 @@
#include <string.h>
#include "Common.h"
#include "StringUtil.h"
// User directory indices for GetUserPath
enum {
@ -226,4 +227,15 @@ private:
} // namespace
// To deal with Windows being dumb at unicode:
template <typename T>
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
{
#ifdef _WIN32
fstream.open(UTF8ToTStr(filename).c_str(), openmode);
#else
fstream.open(filename, openmode);
#endif
}
#endif