mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-30 03:55:40 +00:00
Fixed an issue where a leading Unicode character in the game name could crash the application.
This commit is contained in:
parent
8dc23e2114
commit
43da188b3b
|
@ -92,10 +92,20 @@ GuiGamelistOptions::GuiGamelistOptions(
|
|||
ViewController::FAVORITE_CHAR))
|
||||
isFavorite = true;
|
||||
|
||||
if (mFavoritesSorting && file->getFavorite() && isFavorite)
|
||||
if (mFavoritesSorting && file->getFavorite() && isFavorite) {
|
||||
mCurrentFirstCharacter = ViewController::FAVORITE_CHAR;
|
||||
else
|
||||
mCurrentFirstCharacter = toupper(file->getSortName().front());
|
||||
}
|
||||
else {
|
||||
unsigned char checkCharType = file->getSortName().front();
|
||||
if (checkCharType <= 0x7F) // Normal ASCII character.
|
||||
mCurrentFirstCharacter = toupper(file->getSortName().front());
|
||||
else if (checkCharType >= 0xF0) // Four-byte Unicode character.
|
||||
mCurrentFirstCharacter = file->getSortName().substr(0, 4);
|
||||
else if (checkCharType >= 0xE0) // Three-byte Unicode character.
|
||||
mCurrentFirstCharacter = file->getSortName().substr(0, 3);
|
||||
else if (checkCharType >= 0xC0) // Two-byte Unicode character.
|
||||
mCurrentFirstCharacter = file->getSortName().substr(0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
mJumpToLetterList = std::make_shared<LetterList>(mWindow, getHelpStyle(),
|
||||
|
|
|
@ -489,7 +489,15 @@ void ISimpleGameListView::generateFirstLetterIndex(const std::vector<FileData*>&
|
|||
hasFavorites = true;
|
||||
}
|
||||
else {
|
||||
firstChar = toupper((*it)->getSortName().front());
|
||||
unsigned char checkCharType = (*it)->getSortName().front();
|
||||
if (checkCharType <= 0x7F) // Normal ASCII character.
|
||||
firstChar = toupper((*it)->getSortName().front());
|
||||
else if (checkCharType >= 0xF0) // Four-byte Unicode character.
|
||||
firstChar = (*it)->getSortName().substr(0, 4);
|
||||
else if (checkCharType >= 0xE0) // Three-byte Unicode character.
|
||||
firstChar = (*it)->getSortName().substr(0, 3);
|
||||
else if (checkCharType >= 0xC0) // Two-byte Unicode character.
|
||||
firstChar = (*it)->getSortName().substr(0, 2);
|
||||
mFirstLetterIndex.push_back(firstChar);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue