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 <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2025-04-01 14:08:35 +02:00
parent 4eb0db134a
commit 4d8a4e97bf

View File

@@ -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. "