From 4d8a4e97bf2b661e78aa0b929e1838215c101a2b Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 1 Apr 2025 14:08:35 +0200 Subject: [PATCH] Editor: always use UTF-8 encoding for format operation results We pass the source data as UTF-8 so we also have to handle it as UTF-8. Fixes: QTCREATORBUG-32668 Fixes: QTCREATORBUG-32632 Fixes: QTCREATORBUG-32627 Fixes: QTCREATORBUG-32677 Fixes: QTCREATORBUG-32622 Change-Id: I426b3835a8a1b38f83a53de1cdb656020e239798 Reviewed-by: Eike Ziller --- src/plugins/texteditor/formattexteditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/texteditor/formattexteditor.cpp b/src/plugins/texteditor/formattexteditor.cpp index dd379663ce1..51b0a21d15e 100644 --- a/src/plugins/texteditor/formattexteditor.cpp +++ b/src/plugins/texteditor/formattexteditor.cpp @@ -77,6 +77,7 @@ static FormatOutput format(const FormatInput &input) options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toUrlishString()); Process process; process.setCommand({executable, options}); + process.setUtf8StdOutCodec(); process.runBlocking(5s); if (process.result() != ProcessResult::FinishedWithSuccess) { return Utils::make_unexpected(Tr::tr("Failed to format: %1.") @@ -102,6 +103,7 @@ static FormatOutput format(const FormatInput &input) options.replaceInStrings("%file", input.filePath.toUrlishString()); process.setCommand({executable, options}); process.setWriteData(input.sourceData.toUtf8()); + process.setUtf8StdOutCodec(); process.start(); if (!process.waitForFinished(5s)) { return Utils::make_unexpected(Tr::tr("Cannot call %1 or some other error occurred. "