mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Use ISO-8859-1 as the fallback encoding rather than UTF-8
This commit is contained in:
parent
ed2fc0c627
commit
b05e7b15fe
@ -6,7 +6,7 @@ static QTextCodec *codec(int mib)
|
||||
{
|
||||
QTextCodec *c = QTextCodec::codecForMib(mib);
|
||||
if (!c)
|
||||
qWarning("MIB-%d: No such QTextCodec, using UTF-8", mib);
|
||||
qWarning("MIB-%d: No such QTextCodec, using ISO-8859-1", mib);
|
||||
|
||||
return c;
|
||||
}
|
||||
@ -61,17 +61,17 @@ TextCodec::TextCodec(int codepage)
|
||||
_codec = codec(2258);
|
||||
break;
|
||||
case 65001:
|
||||
_codec = 0;
|
||||
_codec = codec(106);
|
||||
break;
|
||||
default:
|
||||
qWarning("%d: Unknown codepage, using UTF-8", codepage);
|
||||
qWarning("%d: Unknown codepage, using ISO-8859-1", codepage);
|
||||
_codec = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QString TextCodec::toString(const QByteArray &ba)
|
||||
{
|
||||
return _codec ? _codec->toUnicode(ba) : QString::fromUtf8(ba);
|
||||
return _codec ? _codec->toUnicode(ba) : QString::fromLatin1(ba);
|
||||
}
|
||||
|
||||
#else // QT 6.5
|
||||
@ -82,17 +82,19 @@ TextCodec::TextCodec()
|
||||
|
||||
TextCodec::TextCodec(int codepage)
|
||||
{
|
||||
if (codepage != 65001) {
|
||||
if (codepage == 65001)
|
||||
_decoder = QStringDecoder(QStringDecoder::Utf8);
|
||||
else {
|
||||
QByteArray cp(QByteArray("CP") + QByteArray::number(codepage));
|
||||
_decoder = QStringDecoder(cp.constData());
|
||||
|
||||
if (!_decoder.isValid())
|
||||
qWarning("%d: Unknown codepage, using UTF-8", codepage);
|
||||
qWarning("%d: Unknown codepage, using ISO-8859-1", codepage);
|
||||
}
|
||||
}
|
||||
|
||||
QString TextCodec::toString(const QByteArray &ba)
|
||||
{
|
||||
return _decoder.isValid() ? _decoder.decode(ba) : QString::fromUtf8(ba);
|
||||
return _decoder.isValid() ? _decoder.decode(ba) : QString::fromLatin1(ba);
|
||||
}
|
||||
#endif // QT 6.5
|
||||
|
Loading…
Reference in New Issue
Block a user