mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
[Redirector] Update ws2s and s2ws
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
string ws2s(const wstring str)
|
||||
{
|
||||
auto length = WideCharToMultiByte(CP_ACP, 0, str.c_str(), (int)str.length(), NULL, 0, NULL, NULL);
|
||||
auto buffer = new char[length]();
|
||||
auto length = WideCharToMultiByte(CP_ACP, 0, str.c_str(), static_cast<int>(str.length()), NULL, 0, NULL, NULL);
|
||||
auto buffer = new char[length + 1]();
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, str.c_str(), (int)str.length(), buffer, length, NULL, NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, str.c_str(), static_cast<int>(str.length()), buffer, length, NULL, NULL);
|
||||
|
||||
auto data = string(buffer);
|
||||
delete[] buffer;
|
||||
@@ -15,10 +15,10 @@ string ws2s(const wstring str)
|
||||
|
||||
wstring s2ws(const string str)
|
||||
{
|
||||
auto length = MultiByteToWideChar(CP_ACP, 0, str.c_str(), (int)str.length(), NULL, 0);
|
||||
auto buffer = new wchar_t[length]();
|
||||
auto length = MultiByteToWideChar(CP_ACP, 0, str.c_str(), static_cast<int>(str.length()), NULL, 0);
|
||||
auto buffer = new wchar_t[length + 1]();
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, str.c_str(), (int)str.length(), buffer, length);
|
||||
MultiByteToWideChar(CP_ACP, 0, str.c_str(), static_cast<int>(str.length()), buffer, length);
|
||||
|
||||
auto data = wstring(buffer);
|
||||
delete[] buffer;
|
||||
|
||||
Reference in New Issue
Block a user