From d5605cc899f4c2434dacb52424f7960f2dccf366 Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Wed, 31 Jul 2024 17:43:41 +0800 Subject: [PATCH] Fix audio-info.exe for CJK chars --- tools/audio.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/audio.cpp b/tools/audio.cpp index 9ba115aa..41659dcb 100644 --- a/tools/audio.cpp +++ b/tools/audio.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "src/utility.h" @@ -215,15 +216,22 @@ namespace audio { } } - std::wcout - << L"===== Device ====="sv << std::endl - << L"Device ID : "sv << wstring.get() << std::endl - << L"Device name : "sv << no_null((LPWSTR) device_friendly_name.prop.pszVal) << std::endl - << L"Adapter name : "sv << no_null((LPWSTR) adapter_friendly_name.prop.pszVal) << std::endl - << L"Device description : "sv << no_null((LPWSTR) device_desc.prop.pszVal) << std::endl - << L"Device state : "sv << device_state_string << std::endl - << L"Current format : "sv << current_format << std::endl - << std::endl; + wprintf( + L"===== Device =====\n" + L"Device ID : %ls\n" + L"Device name : %ls\n" + L"Adapter name : %ls\n" + L"Device description : %ls\n" + L"Device state : %ls\n" + L"Current format : %ls\n\n", + wstring.get(), + no_null((LPWSTR)device_friendly_name.prop.pszVal), + no_null((LPWSTR)adapter_friendly_name.prop.pszVal), + no_null((LPWSTR)device_desc.prop.pszVal), + device_state_string.c_str(), + current_format.c_str() + ); + } } // namespace audio @@ -247,6 +255,9 @@ main(int argc, char *argv[]) { device_state_filter = 0; } + // Set the locale to support wide characters + std::setlocale(LC_ALL, ""); + for (auto x = 1; x < argc; ++x) { for (auto p = argv[x]; *p != '\0'; ++p) { if (*p == ' ') {