- made Windows backend parts of the console Unicode capable.

This commit is contained in:
Christoph Oelckers 2019-02-15 22:05:26 +01:00
commit b4d96aaef9
5 changed files with 108 additions and 141 deletions

View file

@ -190,8 +190,15 @@ bool DirEntryExists(const char *pathname, bool *isdir)
if (pathname == NULL || *pathname == 0)
return false;
#ifndef _WIN32
struct stat info;
bool res = stat(pathname, &info) == 0;
#else
// Windows must use the wide version of stat to preserve non-standard paths.
auto wstr = WideString(pathname);
struct _stat64i32 info;
bool res = _wstat64i32(wstr.c_str(), &info) == 0;
#endif
if (isdir) *isdir = !!(info.st_mode & S_IFDIR);
return res;
}

View file

@ -1264,6 +1264,7 @@ FString::FString(const wchar_t *copyStr)
int size_needed = WideCharToMultiByte(CP_UTF8, 0, copyStr, (int)len, nullptr, 0, nullptr, nullptr);
AllocBuffer(size_needed);
WideCharToMultiByte(CP_UTF8, 0, copyStr, (int)len, Chars, size_needed, nullptr, nullptr);
Chars[size_needed] = 0;
}
}
@ -1280,6 +1281,7 @@ FString &FString::operator=(const wchar_t *copyStr)
int size_needed = WideCharToMultiByte(CP_UTF8, 0, copyStr, (int)len, nullptr, 0, nullptr, nullptr);
ReallocBuffer(size_needed);
WideCharToMultiByte(CP_UTF8, 0, copyStr, (int)len, Chars, size_needed, nullptr, nullptr);
Chars[size_needed] = 0;
}
return *this;
}