game: better history text canonicalization (should work with UTF-8)

This commit is contained in:
Crypto City 2021-08-15 13:21:32 +00:00
parent 9b6915640b
commit 5c433b3efc

View File

@ -2825,13 +2825,24 @@ void UIPlayerInfoDialog::HandleListHeaderResized(StringHash eventType, VariantMa
}
UIPlayerInfoDialog::HistoryItem::HistoryItem(const TBStr &s):
tb::TBGenericStringItem(s),
canonical(s)
tb::TBGenericStringItem(s)
{
const int len = canonical.Length();
char *ptr = canonical.CStr();
for (int i = 0; i < len; ++i)
ptr[i] = tolower(ptr[i]);
try
{
canonical = tools::utf8canonical(std::string(s.CStr()), [](wint_t c) -> wint_t {
if (c >= 32 && c < 128)
return tolower(c);
return c;
}).c_str();
}
catch(...)
{
canonical = s;
const int len = canonical.Length();
char *ptr = canonical.CStr();
for (int i = 0; i < len; ++i)
ptr[i] = tolower(ptr[i]);
}
}
bool UIPlayerInfoDialog::HistorySource::Filter(int index, const TBStr &filter)