CueParser: Detect encoding

This commit is contained in:
Jonas Kvinge 2023-01-08 23:40:56 +01:00
parent 7bfa75102c
commit 02f2b8b6f0
1 changed files with 10 additions and 0 deletions

View File

@ -30,6 +30,9 @@
#include <QStringList>
#include <QRegularExpression>
#include <QTextStream>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
# include <QStringConverter>
#endif
#include "core/logging.h"
#include "utilities/timeconstants.h"
@ -63,6 +66,13 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
QTextStream text_stream(device);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const std::optional<QStringConverter::Encoding> encoding = QStringConverter::encodingForData(device->peek(1024));
if (encoding.has_value()) {
text_stream.setEncoding(encoding.value());
}
#endif
QString dir_path = dir.absolutePath();
// read the first line already
QString line = text_stream.readLine();