1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 09:23:53 +01:00
dxvk/src/util/util_string.cpp

44 lines
861 B
C++
Raw Normal View History

2018-07-21 12:51:50 +02:00
#include "util_string.h"
namespace dxvk::str {
std::string fromws(const WCHAR *ws) {
size_t len = ::WideCharToMultiByte(CP_UTF8,
2018-07-21 12:51:50 +02:00
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,
2018-07-21 12:51:50 +02:00
&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;
}
2018-07-21 12:51:50 +02:00
}