Import Strong Logger & Config System

This commit is contained in:
Xphalnos 2025-06-18 18:07:20 +02:00
parent 92d4e7a8d3
commit 014b236228
48 changed files with 3281 additions and 734 deletions

65
core/Base/StringUtil.cpp Normal file
View file

@ -0,0 +1,65 @@
// Copyright 2025 Xenon Emulator Project. All rights reserved.
#include "StringUtil.h"
namespace Base {
#ifdef _WIN32
static std::wstring CPToUTF16(u32 code_page, std::string_view input) {
const s32 size =
::MultiByteToWideChar(code_page, 0, input.data(), static_cast<s32>(input.size()), nullptr, 0);
if (size == 0) {
return {};
}
std::wstring output(size, L'\0');
if (size != ::MultiByteToWideChar(code_page, 0, input.data(), static_cast<s32>(input.size()),
&output[0], static_cast<s32>(output.size()))) {
output.clear();
}
return output;
}
#endif // ifdef _WIN32
std::string UTF16ToUTF8(const std::wstring_view &input) {
#ifdef _WIN32
const s32 size = ::WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<s32>(input.size()),
nullptr, 0, nullptr, nullptr);
if (size == 0) {
return {};
}
std::string output(size, '\0');
if (size != ::WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<s32>(input.size()),
&output[0], static_cast<s32>(output.size()), nullptr,
nullptr)) {
output.clear();
}
return output;
#else
// Very hacky way to get cross-platform wstring conversion
return std::filesystem::path(input).string();
#endif // ifdef _WIN32
}
std::wstring UTF8ToUTF16W(const std::string_view &input) {
#ifdef _WIN32
return CPToUTF16(CP_UTF8, input);
#else
// Very hacky way to get cross-platform wstring conversion
return std::filesystem::path(input).wstring();
#endif // ifdef _WIN32
}
std::string ToLower(const std::string &str) {
std::string out = str;
std::transform(str.begin(), str.end(), out.data(), ::tolower);
return out;
}
} // namespace Base