mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 12:28:31 +01:00
Fix some Latin1 encoding guessing.
This commit is contained in:
parent
90fc1481e6
commit
579c7cc592
@ -229,14 +229,9 @@ QTextCodec* UniversalEncodingHandler::Guess(const TagLib::String& input) {
|
||||
if (input.isLatin1()) {
|
||||
qWarning() << "Extended ASCII... possibly should be CP866 or windows-1251 instead";
|
||||
std::string broken = input.toCString(true);
|
||||
std::string fixed;
|
||||
if (broken.size() > input.size()) {
|
||||
fixed = QString::fromUtf8(broken.c_str()).toStdString();
|
||||
std::string fixed = QString::fromUtf8(broken.c_str()).toStdString();
|
||||
QTextCodec* codec = Guess(fixed.c_str());
|
||||
return codec;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return QTextCodec::codecForName("UTF-8");
|
||||
}
|
||||
|
@ -178,4 +178,12 @@ TEST_F(SongTest, DecodesUtf8AsUtf8) {
|
||||
EXPECT_EQ(QString::fromUtf8("’"), fixed);
|
||||
}
|
||||
|
||||
TEST_F(SongTest, DecodesAmbiguousLatin1AndWindows1252) {
|
||||
const char latin1[] = { 0x53, 0x75, 0x64, 0xe1, 0x66, 0x72, 0x69, 0x63, 0x61, 0x00 };
|
||||
TagLib::String str(latin1, TagLib::String::Latin1);
|
||||
QString fixed = UniversalEncodingHandler(NS_FILTER_NON_CJK).FixEncoding(str);
|
||||
EXPECT_EQ(9, fixed.length());
|
||||
EXPECT_EQ(QString::fromUtf8("Sudáfrica"), fixed);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user