comparison main/MainWindow.cpp @ 911:c08df7de50f6

Specify UTF-8 encoding when writing XML formats -- the XML header always indicated UTF-8 but the QTextStream defaulted to local encoding which is generally not UTF-8 on Windows
author Chris Cannam
date Mon, 02 Mar 2015 17:20:24 +0000
parents 35ce47084c84
children 096634fc3f19
comparison
equal deleted inserted replaced
909:d0b89689f2b4 911:c08df7de50f6
106 #include <QTreeView> 106 #include <QTreeView>
107 #include <QFile> 107 #include <QFile>
108 #include <QFileInfo> 108 #include <QFileInfo>
109 #include <QDir> 109 #include <QDir>
110 #include <QTextStream> 110 #include <QTextStream>
111 #include <QTextCodec>
111 #include <QProcess> 112 #include <QProcess>
112 #include <QShortcut> 113 #include <QShortcut>
113 #include <QSettings> 114 #include <QSettings>
114 #include <QDateTime> 115 #include <QDateTime>
115 #include <QProcess> 116 #include <QProcess>
2724 QFile file(path); 2725 QFile file(path);
2725 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { 2726 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
2726 error = tr("Failed to open file %1 for writing").arg(path); 2727 error = tr("Failed to open file %1 for writing").arg(path);
2727 } else { 2728 } else {
2728 QTextStream out(&file); 2729 QTextStream out(&file);
2730 out.setCodec(QTextCodec::codecForName("UTF-8"));
2729 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 2731 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
2730 << "<!DOCTYPE sonic-visualiser>\n" 2732 << "<!DOCTYPE sonic-visualiser>\n"
2731 << "<sv>\n" 2733 << "<sv>\n"
2732 << " <data>\n"; 2734 << " <data>\n";
2733 2735