Consolidate the host's UTF-8/wide conversions into util/utf8.hpp

Five files each carried their own copy of the WideCharToMultiByte /
MultiByteToWideChar UTF-8 conversion (injection_panel, audio_overrides,
imgui_layer's to_utf8, main's harness widen, and vk_layer_setup's inline
form). Replace them all with coop::narrow / coop::widen from one header.

audio_panel's image_basename dropped its lossy `c & 0x7F` ASCII mask for
the proper narrow(), so a non-ASCII game exe name is no longer mangled
in log lines.
This commit is contained in:
2026-07-12 09:23:40 +02:00
parent 246289e386
commit 1eee482165
7 changed files with 54 additions and 81 deletions

View File

@@ -35,6 +35,7 @@
#include "log_panel.hpp"
#include "test_harness.hpp"
#include "ui/app_chrome.hpp"
#include "util/utf8.hpp"
#include "vk_layer_setup.hpp"
namespace
@@ -91,17 +92,7 @@ void draw_screenshot_toast(double seconds_since, const std::string& name)
}
#ifdef COOP_TEST_HARNESS
std::wstring widen(const std::string& s)
{
if (s.empty())
{
return {};
}
const int n = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), static_cast<int>(s.size()), nullptr, 0);
std::wstring w(static_cast<std::size_t>(n), L'\0');
MultiByteToWideChar(CP_UTF8, 0, s.c_str(), static_cast<int>(s.size()), w.data(), n);
return w;
}
using coop::widen;
// Run a test-harness command on the main thread, hitting the same code the UI buttons do.
// Returns a one-line response the driver reads back.