use the same table for UCharToFullSizeKana and UCharToSmallKana

This commit is contained in:
Vincent Wei
2019-01-18 16:24:56 +08:00
parent 54288e5687
commit 195363dc82
+28
View File
@@ -4794,6 +4794,7 @@ Uchar32 GUIAPI UCharToFullSizeKana (Uchar32 uc)
return uc;
}
#if 0 // VincentWei: use kana_small_to_full_size_table instead
static const struct UCharMap kana_full_size_to_small_table [] = {
{ /*あ*/ 0x3041, /*ぁ*/ 0x3041},
{ /*い*/ 0x3043, /*ぃ*/ 0x3043},
@@ -4871,5 +4872,32 @@ Uchar32 GUIAPI UCharToSmallKana (Uchar32 uc)
return uc;
}
#endif // VincentWei: use kana_small_to_full_size_table instead
/** Converts a glyph to small Kana. */
Uchar32 GUIAPI UCharToSmallKana (Uchar32 uc)
{
unsigned int lower = 0;
unsigned int upper = TABLESIZE (kana_small_to_full_size_table) - 1;
int mid = TABLESIZE (kana_small_to_full_size_table) / 2;
if (uc < kana_small_to_full_size_table[lower].other
|| uc < kana_small_to_full_size_table[upper].other)
return uc;
do {
if (uc < kana_small_to_full_size_table[mid].other)
upper = mid - 1;
else if (uc > kana_small_to_full_size_table[mid].other)
lower = mid + 1;
else
return kana_small_to_full_size_table[mid].one;
mid = (lower + upper) / 2;
} while (lower <= upper);
return uc;
}
#endif /* _MGCHARSET_UNICODE */