mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +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);
|
QTextCodec *c = QTextCodec::codecForMib(mib);
|
||||||
if (!c)
|
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;
|
return c;
|
||||||
}
|
}
|
||||||
@ -61,17 +61,17 @@ TextCodec::TextCodec(int codepage)
|
|||||||
_codec = codec(2258);
|
_codec = codec(2258);
|
||||||
break;
|
break;
|
||||||
case 65001:
|
case 65001:
|
||||||
_codec = 0;
|
_codec = codec(106);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning("%d: Unknown codepage, using UTF-8", codepage);
|
qWarning("%d: Unknown codepage, using ISO-8859-1", codepage);
|
||||||
_codec = 0;
|
_codec = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextCodec::toString(const QByteArray &ba)
|
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
|
#else // QT 6.5
|
||||||
@ -82,17 +82,19 @@ TextCodec::TextCodec()
|
|||||||
|
|
||||||
TextCodec::TextCodec(int codepage)
|
TextCodec::TextCodec(int codepage)
|
||||||
{
|
{
|
||||||
if (codepage != 65001) {
|
if (codepage == 65001)
|
||||||
|
_decoder = QStringDecoder(QStringDecoder::Utf8);
|
||||||
|
else {
|
||||||
QByteArray cp(QByteArray("CP") + QByteArray::number(codepage));
|
QByteArray cp(QByteArray("CP") + QByteArray::number(codepage));
|
||||||
_decoder = QStringDecoder(cp.constData());
|
_decoder = QStringDecoder(cp.constData());
|
||||||
|
|
||||||
if (!_decoder.isValid())
|
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)
|
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
|
#endif // QT 6.5
|
||||||
|
Loading…
Reference in New Issue
Block a user