From fd0d5b510c34991c6f4b286d9dc1c5d11d38c091 Mon Sep 17 00:00:00 2001 From: panav Date: Fri, 19 Dec 2025 23:34:39 +0530 Subject: [PATCH] Fix: Explicitly use UTF-8 encoding for layout load/save to support Unicode strings --- plotjuggler_app/mainwindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plotjuggler_app/mainwindow.cpp b/plotjuggler_app/mainwindow.cpp index 9f5f42a22..61ab169c7 100644 --- a/plotjuggler_app/mainwindow.cpp +++ b/plotjuggler_app/mainwindow.cpp @@ -1901,18 +1901,25 @@ bool MainWindow::loadLayoutFromFile(QString filename) return false; } + // Read file content with explicit UTF-8 encoding to handle Unicode characters + QTextStream stream(&file); + stream.setCodec("UTF-8"); + QString fileContent = stream.readAll(); + file.close(); + QString errorStr; int errorLine, errorColumn; QDomDocument domDocument; - if (!domDocument.setContent(&file, true, &errorStr, &errorLine, &errorColumn)) + if (!domDocument.setContent(fileContent, true, &errorStr, &errorLine, &errorColumn)) { QMessageBox::information(window(), tr("XML Layout"), tr("Parse error at line %1:\n%2").arg(errorLine).arg(errorStr)); return false; } + //------------------------------------------------- // refresh plugins QDomElement root = domDocument.namedItem("root").toElement(); @@ -3054,6 +3061,7 @@ void MainWindow::on_buttonSaveLayout_clicked() if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); + stream.setCodec("UTF-8"); stream << doc.toString() << "\n"; } }