Merge encoding_convert_rct2_to_unicode() with generic counterpart

This commit is contained in:
Gymnasiast 2022-05-01 17:59:52 +02:00
parent 62d5a69051
commit 598675ca8f
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
1 changed files with 4 additions and 9 deletions

View File

@ -108,15 +108,10 @@ static int32_t encoding_search_compare(const void *pKey, const void *pEntry)
return 0;
}
static wchar_t encoding_convert_x_to_unicode(wchar_t code, const encoding_convert_entry *table, size_t count)
{
encoding_convert_entry * entry = static_cast<encoding_convert_entry *>(std::bsearch(&code, table, count, sizeof(encoding_convert_entry), encoding_search_compare));
if (entry == nullptr)
return code;
return entry->unicode;
}
wchar_t encoding_convert_rct2_to_unicode(wchar_t rct2str)
{
return encoding_convert_x_to_unicode(rct2str, RCT2ToUnicodeTable, std::size(RCT2ToUnicodeTable));
encoding_convert_entry * entry = static_cast<encoding_convert_entry *>(std::bsearch(&rct2str, RCT2ToUnicodeTable, std::size(RCT2ToUnicodeTable), sizeof(encoding_convert_entry), encoding_search_compare));
if (entry == nullptr)
return rct2str;
return entry->unicode;
}