From: James Turner Date: Sun, 3 Jul 2016 21:50:39 +0000 (+0100) Subject: Windows string conversion for SGPath X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9234351e8de3f91516050fa267cc990244cd1dc8;p=simgear.git Windows string conversion for SGPath --- diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx index a2f6842f..d504e411 100644 --- a/simgear/misc/sg_path.cxx +++ b/simgear/misc/sg_path.cxx @@ -987,8 +987,11 @@ std::string SGPath::join(const std::vector& paths, const std::string& jo std::wstring SGPath::wstr() const { #ifdef SG_WINDOWS - size_t buflen = mbstowcs(NULL, path.c_str(), 0)+1; - wchar_t* wideBuf = (wchar_t*)malloc(buflen * sizeof(int)); + simgear::strutils::WCharVec ws = simgear::strutils::convertUtf8ToWString(path); + return std::wstring(ws.data(), ws.size()); +#else + const size_t buflen = mbstowcs(NULL, path.c_str(), 0)+1; + wchar_t* wideBuf = (wchar_t*)malloc(buflen * sizeof(wchar_t)); if (wideBuf) { size_t count = mbstowcs(wideBuf, path.c_str(), buflen); if (count == (size_t)-1) {