Skip to content

Commit 63e9044

Browse files
committed
GUI - force UTF-8 encoding on save
Previously this wasn't forced which caused encoding issues on Windows with certain UTF-8 contents.
1 parent 38fd173 commit 63e9044

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/gui/qt/mainwindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3337,14 +3337,16 @@ bool MainWindow::saveFile(const QString& fileName, SonicPiScintilla* text)
33373337
}
33383338

33393339
QTextStream out(&file);
3340-
3340+
out.setCodec("UTF-8");
33413341
QApplication::setOverrideCursor(Qt::WaitCursor);
33423342
QString code = text->text();
33433343
#if defined(Q_OS_WIN)
33443344
code.replace("\n", "\r\n"); // CRLF for Windows users
33453345
code.replace("\r\r\n", "\r\n"); // don't double-replace if already encoded
33463346
#endif
33473347
out << code;
3348+
out.flush();
3349+
file.close();
33483350
QApplication::restoreOverrideCursor();
33493351

33503352
statusBar()->showMessage(tr("File saved..."), 2000);

0 commit comments

Comments
 (0)