QString::fromLocal8Bit() doesn't work as expected, as we explicitly set the CodecForLocale to UTF-8 in the initialization code. Therefore we can't use QString::fromLocal8Bit() at places where the system's default Codec is needed. Instead we will now get the actual system Codec via QTextCodec::codecForName("System") at those places. That's not nice, but solves the problem.

This commit is contained in:
LoRd_MuldeR 2011-12-10 01:59:45 +01:00
parent 545b9b4967
commit 6770f1ec90
5 changed files with 37 additions and 29 deletions

View File

@ -543,44 +543,44 @@
<context>
<name>CueSheetModel</name>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="208"/>
<location filename="../../src/Model_CueSheet.cpp" line="209"/>
<source>No.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="211"/>
<location filename="../../src/Model_CueSheet.cpp" line="212"/>
<source>File / Track</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="214"/>
<location filename="../../src/Model_CueSheet.cpp" line="215"/>
<source>Index</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="217"/>
<location filename="../../src/Model_CueSheet.cpp" line="218"/>
<source>Duration</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="243"/>
<location filename="../../src/Model_CueSheet.cpp" line="244"/>
<source>File %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="258"/>
<location filename="../../src/Model_CueSheet.cpp" line="259"/>
<source>Track %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="267"/>
<location filename="../../src/Model_CueSheet.cpp" line="275"/>
<location filename="../../src/Model_CueSheet.cpp" line="268"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<source>Unknown Artist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="271"/>
<location filename="../../src/Model_CueSheet.cpp" line="275"/>
<location filename="../../src/Model_CueSheet.cpp" line="272"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<source>Unknown Title</source>
<translation type="unfinished"></translation>
</message>

View File

@ -543,44 +543,44 @@
<context>
<name>CueSheetModel</name>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="208"/>
<location filename="../../src/Model_CueSheet.cpp" line="209"/>
<source>No.</source>
<translation type="unfinished">Numer.</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="211"/>
<location filename="../../src/Model_CueSheet.cpp" line="212"/>
<source>File / Track</source>
<translation type="unfinished">Plik/ŚcieżKa</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="214"/>
<location filename="../../src/Model_CueSheet.cpp" line="215"/>
<source>Index</source>
<translation type="unfinished">Indeks</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="217"/>
<location filename="../../src/Model_CueSheet.cpp" line="218"/>
<source>Duration</source>
<translation type="unfinished">Czas trwania</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="243"/>
<location filename="../../src/Model_CueSheet.cpp" line="244"/>
<source>File %1</source>
<translation type="unfinished">Plik %1</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="258"/>
<location filename="../../src/Model_CueSheet.cpp" line="259"/>
<source>Track %1</source>
<translation type="unfinished">Ścieżka %1</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="267"/>
<location filename="../../src/Model_CueSheet.cpp" line="275"/>
<location filename="../../src/Model_CueSheet.cpp" line="268"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<source>Unknown Artist</source>
<translation type="unfinished">Nieznany Artysta</translation>
</message>
<message>
<location filename="../../src/Model_CueSheet.cpp" line="271"/>
<location filename="../../src/Model_CueSheet.cpp" line="275"/>
<location filename="../../src/Model_CueSheet.cpp" line="272"/>
<location filename="../../src/Model_CueSheet.cpp" line="276"/>
<source>Unknown Title</source>
<translation type="unfinished">Nieznany Tytuł</translation>
</message>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 7
#define VER_LAMEXP_BUILD 803
#define VER_LAMEXP_BUILD 804
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -28,6 +28,7 @@
#include <QFileInfo>
#include <QFont>
#include <QTime>
#include <QTextCodec>
#include <float.h>
#include <limits>
@ -557,6 +558,9 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
return 2;
}
//Get system local Codec
const QTextCodec *codec = QTextCodec::codecForName("System");
//Check for UTF-8 BOM in order to guess encoding
bool bUTF8 = false, bForceLatin1 = false;
QByteArray bomCheck = cueFile.peek(128);
@ -569,7 +573,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
{
const QString replacementSymbol = QString(QChar(QChar::ReplacementCharacter));
QByteArray data = cueFile.peek(1048576);
if((!data.isEmpty()) && QString::fromLocal8Bit(data.constData(), data.size()).contains(replacementSymbol))
if((!data.isEmpty()) && codec->toUnicode(data.constData(), data.size()).contains(replacementSymbol))
{
qWarning("Decoding error using local 8-Bit codepage. Enforcing Latin-1.");
bForceLatin1 = true;
@ -611,7 +615,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
break;
}
QString line = bUTF8 ? QString::fromUtf8(lineData.constData(), lineData.size()).trimmed() : (bForceLatin1 ? QString::fromLatin1(lineData.constData(), lineData.size()).trimmed() : QString::fromLocal8Bit(lineData.constData(), lineData.size()).trimmed());
QString line = (bUTF8 ? QString::fromUtf8(lineData.constData(), lineData.size()) : (bForceLatin1 ? QString::fromLatin1(lineData.constData(), lineData.size()) : codec->toUnicode(lineData.constData(), lineData.size()))).trimmed();
/* --- FILE --- */
if(rxFile.indexIn(line) >= 0)

View File

@ -29,6 +29,7 @@
#include <QDate>
#include <QTime>
#include <QDebug>
#include <QTextCodec>
//Un-escape XML characters
static const struct
@ -133,6 +134,8 @@ bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, con
{
QByteArray line = data.readLine();
const bool preferUTF8 = data.fileName().endsWith(".m3u8", Qt::CaseInsensitive);
const QTextCodec *codec = QTextCodec::codecForName("System");
while(line.size() > 0)
{
@ -141,12 +144,12 @@ bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, con
if(preferUTF8)
{
filePath[0] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromLocal8Bit(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(codec->toUnicode(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
}
else
{
filePath[0] = QString(QDir::fromNativeSeparators(QString::fromLocal8Bit(line.constData(), line.size()).trimmed()));
filePath[0] = QString(QDir::fromNativeSeparators(codec->toUnicode(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
}
@ -179,16 +182,17 @@ bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, con
bool PlaylistImporter::parsePlaylist_pls(QFile &data, QStringList &fileList, const QDir &baseDir, const QDir &rootDir)
{
QRegExp plsEntry("File(\\d+)=(.+)", Qt::CaseInsensitive);
const QTextCodec *codec = QTextCodec::codecForName("System");
QByteArray line = data.readLine();
while(line.size() > 0)
{
QString filePath[3];
filePath[0] = QString(QDir::fromNativeSeparators(QString::fromLocal8Bit(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
filePath[0] = QString(QDir::fromNativeSeparators(codec->toUnicode(line.constData(), line.size()).trimmed()));
filePath[1] = QString(QDir::fromNativeSeparators(QString::fromLatin1(line.constData(), line.size()).trimmed()));
filePath[2] = QString(QDir::fromNativeSeparators(QString::fromUtf8(line.constData(), line.size()).trimmed()));
for(size_t i = 0; i < 3; i++)
{
if(!filePath[i].contains(QChar(QChar::ReplacementCharacter)))