Some code updates

This commit is contained in:
GabsPuNs
2026-04-09 00:57:05 -04:00
parent fb12bc0860
commit abd2d848cf
59 changed files with 241 additions and 257 deletions

View File

@@ -18,7 +18,7 @@ namespace ServerRuntime
return std::string();
}
int charCount = WideCharToMultiByte(CP_UTF8, 0, value.c_str(), (int)value.length(), NULL, 0, NULL, NULL);
int charCount = WideCharToMultiByte(CP_UTF8, 0, value.c_str(), (int)value.length(), nullptr, 0, nullptr, nullptr);
if (charCount <= 0)
{
return std::string();
@@ -26,22 +26,22 @@ namespace ServerRuntime
std::string utf8;
utf8.resize(charCount);
WideCharToMultiByte(CP_UTF8, 0, value.c_str(), (int)value.length(), &utf8[0], charCount, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, value.c_str(), (int)value.length(), &utf8[0], charCount, nullptr, nullptr);
return utf8;
}
std::wstring Utf8ToWide(const char *value)
{
if (value == NULL || value[0] == 0)
if (value == nullptr || value[0] == 0)
{
return std::wstring();
}
int wideCount = MultiByteToWideChar(CP_UTF8, 0, value, -1, NULL, 0);
int wideCount = MultiByteToWideChar(CP_UTF8, 0, value, -1, nullptr, 0);
if (wideCount <= 0)
{
// Fall back to the current ANSI code page so legacy non-UTF-8 inputs remain readable.
wideCount = MultiByteToWideChar(CP_ACP, 0, value, -1, NULL, 0);
wideCount = MultiByteToWideChar(CP_ACP, 0, value, -1, nullptr, 0);
if (wideCount <= 0)
{
return std::wstring();