From 9dbb36ead0263b548bdb3f23600fce88f5f253d6 Mon Sep 17 00:00:00 2001 From: BearOso Date: Thu, 10 Aug 2023 15:09:05 -0500 Subject: [PATCH] Qt: Changes to ensure UTF-8 encoding on windows. --- qt/src/EmuCanvasOpenGL.cpp | 4 ++-- qt/src/EmuCanvasVulkan.cpp | 4 ++-- qt/src/main.cpp | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qt/src/EmuCanvasOpenGL.cpp b/qt/src/EmuCanvasOpenGL.cpp index 71557d9a..250cc33e 100644 --- a/qt/src/EmuCanvasOpenGL.cpp +++ b/qt/src/EmuCanvasOpenGL.cpp @@ -212,7 +212,7 @@ void EmuCanvasOpenGL::loadShaders() } else { - setlocale(LC_NUMERIC, "C"); + auto previous_locale = setlocale(LC_NUMERIC, "C"); shader = std::make_unique(); if (!shader->load_shader(config->shader.c_str())) { @@ -220,7 +220,7 @@ void EmuCanvasOpenGL::loadShaders() using_shader = false; createStockShaders(); } - setlocale(LC_NUMERIC, ""); + setlocale(LC_NUMERIC, previous_locale); } } diff --git a/qt/src/EmuCanvasVulkan.cpp b/qt/src/EmuCanvasVulkan.cpp index d604ee70..486653d9 100644 --- a/qt/src/EmuCanvasVulkan.cpp +++ b/qt/src/EmuCanvasVulkan.cpp @@ -127,14 +127,14 @@ void EmuCanvasVulkan::tryLoadShader() if (config->use_shader && !config->shader.empty()) { shader_chain = std::make_unique(context.get()); - setlocale(LC_NUMERIC, "C"); + auto previous_locale = setlocale(LC_NUMERIC, "C"); current_shader = config->shader; if (!shader_chain->load_shader_preset(config->shader)) { printf("Couldn't load shader preset: %s\n", config->shader.c_str()); shader_chain.reset(); } - setlocale(LC_NUMERIC, ""); + setlocale(LC_NUMERIC, previous_locale); } if (!shader_chain) diff --git a/qt/src/main.cpp b/qt/src/main.cpp index 7ee6acf6..13ef65e7 100644 --- a/qt/src/main.cpp +++ b/qt/src/main.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #ifndef _WIN32 @@ -16,6 +17,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, const char *lpCmdLine, { char **argv = nullptr; int argc = 0; + setlocale(LC_ALL, ".utf8"); #else int main(int argc, char *argv[]) {