]> git.mxchange.org Git - simgear.git/commitdiff
Windows string conversion for SGPath
authorJames Turner <zakalawe@mac.com>
Sun, 3 Jul 2016 21:50:39 +0000 (22:50 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
simgear/misc/sg_path.cxx

index a2f6842feabb12df01b9aed14c0f6d8cf5903857..d504e411b7948c1946d2c9391beb6a923c2ca53e 100644 (file)
@@ -987,8 +987,11 @@ std::string SGPath::join(const std::vector<SGPath>& 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) {