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"; } }