diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 206e2f564..9df1d8a08 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -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(), diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 337e253d7..7ccd9f476 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -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); } }