1
0
mirror of synced 2025-01-25 15:53:43 +01:00

impr: Replace codecvt with libwolv conversion functions

This commit is contained in:
WerWolv 2024-12-14 22:20:48 +01:00
parent ed0a94659e
commit f39f395393
5 changed files with 8 additions and 11 deletions

View File

@ -73,7 +73,7 @@ jobs:
python3 -m venv venv
. venv/bin/activate
pip3 install gcovr
gcovr --gcov-executable /usr/bin/gcov-14 -e ".+yara_rules.+" -r . build --xml coverage_report.xml --verbose
gcovr --gcov-executable /usr/bin/gcov-14 -e ".+yara_rules.+" -e ".+third_party.+" -e ".+external.+" -r . build --xml coverage_report.xml --verbose
- name: Upload coverage reports to Codecov
env:

@ -1 +1 @@
Subproject commit eb826d70d32fc5dd27541514cc56dc741d94416a
Subproject commit 759035de2d966c07f81638e2a1f80539a0f0daec

@ -1 +1 @@
Subproject commit 1057425e1b945ab61b45bcfe4a2018ef1b785f75
Subproject commit c7cd053979fec6fffe4d924593e97efa65a8a4d5

View File

@ -8,6 +8,7 @@
#include <hex/helpers/default_paths.hpp>
#include <wolv/utils/guards.hpp>
#include <wolv/utils/string.hpp>
#if defined(OS_WINDOWS)
@ -47,7 +48,7 @@ namespace hex::init {
// Skip the first argument (the executable path) and convert the rest to a vector of UTF-8 strings
for (int i = 1; i < argc; i += 1) {
std::wstring wcharArg = convertedCommandLine[i];
std::string utf8Arg = std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().to_bytes(wcharArg);
std::string utf8Arg = wolv::util::wstringToUtf8(wcharArg);
args.push_back(utf8Arg);
}

View File

@ -351,16 +351,12 @@ namespace hex::plugin::builtin {
auto c = hex::changeEndianness(wideChar, endian);
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter("Invalid");
auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : converter.to_bytes(c));
auto value = hex::format("{0}", c <= 255 ? makePrintable(c) : wolv::util::wstringToUtf8(std::wstring(&c, 1)));
return [value] { ImGuiExt::TextFormatted("'{0}'", value.c_str()); return value; };
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter("Invalid");
std::vector<u8> bytes;
auto wideString = converter.from_bytes(value.c_str());
auto wideString = wolv::util::utf8ToWstring(value.c_str(), "Invalid");
std::copy(wideString.begin(), wideString.end(), std::back_inserter(bytes));
if (endian != std::endian::native)
@ -449,7 +445,7 @@ namespace hex::plugin::builtin {
[](auto c) { return c == 0x00; });
buffer.erase(it, buffer.end());
auto string = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>("Invalid").to_bytes(stringBuffer.data());
auto string = wolv::util::utf16ToUtf8(stringBuffer, "Invalid");
value = copyValue = hex::encodeByteString({ string.begin(), string.end() });
if (value.size() > MaxStringLength) {