Dota2Patcher
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1
#pragma once
2
3
class
Utils
{
4
public
:
5
static
optional<string>
wchar_to_string
(
const
wchar_t
* wideStr) {
6
int
size_needed = WideCharToMultiByte(CP_UTF8, 0, wideStr, -1,
nullptr
, 0,
nullptr
,
nullptr
);
7
if
(size_needed <= 0)
8
return
nullopt;
9
10
string
result(size_needed - 1, 0);
11
WideCharToMultiByte(CP_UTF8, 0, wideStr, -1, &result[0], size_needed,
nullptr
,
nullptr
);
12
return
result;
13
}
14
15
static
std::wstring
string_to_wstring
(
const
string
& str) {
16
int
size_needed = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
17
std::wstring wstr(size_needed, 0);
18
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &wstr[0], size_needed);
19
return
wstr;
20
}
21
};
22
Utils
Definition
Utils.h:3
Utils::string_to_wstring
static std::wstring string_to_wstring(const string &str)
Definition
Utils.h:15
Utils::wchar_to_string
static optional< string > wchar_to_string(const wchar_t *wideStr)
Definition
Utils.h:5
Utils
Utils.h
Generated by
1.9.8