mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-13 22:36:58 +00:00
Major project restructuring
Remove unecessary files and made the tree much more cleaner. Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit is contained in:
parent
13b2e741b9
commit
05c4f7025f
62 changed files with 2698 additions and 2453 deletions
71
core/common/StringUtil.cpp
Normal file
71
core/common/StringUtil.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue