summaryrefslogtreecommitdiffstats
path: root/src/libs/dxvk-native-1.9.2a/src/util/platform/util_string_win32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dxvk-native-1.9.2a/src/util/platform/util_string_win32.cpp')
-rw-r--r--src/libs/dxvk-native-1.9.2a/src/util/platform/util_string_win32.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libs/dxvk-native-1.9.2a/src/util/platform/util_string_win32.cpp b/src/libs/dxvk-native-1.9.2a/src/util/platform/util_string_win32.cpp
new file mode 100644
index 00000000..2151c1e4
--- /dev/null
+++ b/src/libs/dxvk-native-1.9.2a/src/util/platform/util_string_win32.cpp
@@ -0,0 +1,43 @@
+#include "util_string.h"
+
+namespace dxvk::str {
+ std::string fromws(const WCHAR *ws) {
+ size_t len = ::WideCharToMultiByte(CP_UTF8,
+ 0, ws, -1, nullptr, 0, nullptr, nullptr);
+
+ if (len <= 1)
+ return "";
+
+ len -= 1;
+
+ std::string result;
+ result.resize(len);
+ ::WideCharToMultiByte(CP_UTF8, 0, ws, -1,
+ &result.at(0), len, nullptr, nullptr);
+ return result;
+ }
+
+
+ void tows(const char* mbs, WCHAR* wcs, size_t wcsLen) {
+ ::MultiByteToWideChar(
+ CP_UTF8, 0, mbs, -1,
+ wcs, wcsLen);
+ }
+
+ std::wstring tows(const char* mbs) {
+ size_t len = ::MultiByteToWideChar(CP_UTF8,
+ 0, mbs, -1, nullptr, 0);
+
+ if (len <= 1)
+ return L"";
+
+ len -= 1;
+
+ std::wstring result;
+ result.resize(len);
+ ::MultiByteToWideChar(CP_UTF8, 0, mbs, -1,
+ &result.at(0), len);
+ return result;
+ }
+
+}