From 5e122b9991d45a27373579407091a05aed38c9c8 Mon Sep 17 00:00:00 2001 From: NoonLeu <76778265+NoonLeu@users.noreply.github.com> Date: Tue, 11 May 2021 01:27:21 +0800 Subject: [PATCH] Update decoder.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用wstring解决中日韩文字在Windows系统console中显示为乱码的问题 --- src/decoder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/decoder.cpp b/src/decoder.cpp index ad4df2b..c9a1559 100644 --- a/src/decoder.cpp +++ b/src/decoder.cpp @@ -61,7 +61,14 @@ static const std::regex ogg_regex{"\\.qmcogg$"}; static const std::regex flac_regex{"\\.qmcflac$"}; void sub_process(std::string dir) { - std::cout << "decode: " + dir << std::endl; + std::wstring wdir; + wdir.resize(("Decode:"+dir).size()); + int newSize = MultiByteToWideChar( + CP_UTF8, 0, ("Decode:"+dir).c_str(), static_cast(("Decode:"+dir).length()), + const_cast(wdir.c_str()), static_cast(wdir.size())); + wdir.resize(newSize); + std::wcout.imbue(std::locale("chs")); + std::wcout << wdir << std::endl;//使用wstring解决中日韩文字乱码问题(输出语句为wcout) std::string outloc(dir); auto mp3_outloc = regex_replace(outloc, mp3_regex, ".mp3");