capitalize more special chcaracters

This commit is contained in:
pswid
2023-01-21 12:09:17 +01:00
parent 7e174a1b7d
commit 5e41481e27

View File

@@ -679,20 +679,22 @@ std::string Helpers::toUpper(std::string const & s) {
}
// capitalizes one UTF-8 character in char array
// works with Latin1 (1 byte) and Polish (2 bytes) characters
// works with Latin1 (1 byte), Polish amd some other (2 bytes) characters
// TODO add special characters that occur in other supported languages
void Helpers::CharToUpperUTF8(char * c) {
switch (*c) {
case 0xC3:
if (*(c + 1) == 0xB3) //ó (0xC3,0xB3) -> Ó (0xC3,0x93)
*(c + 1) = 0x93;
// grave, acute, circumflex, diaeresis, etc.
if ((*(c + 1) >= 0xA0) && (*(c + 1) <= 0xBE)) {
*(c + 1) -= 0x20;
}
break;
case 0xC4:
switch (*(c + 1)) {
case 0x85: //ą (0xC4,0x85) -> Ą (0xC4,0x84)
case 0x87: //ć (0xC4,0x87) -> Ć (0xC4,0x86)
case 0x99: //ę (0xC4,0x99) -> Ę (0xC4,0x98)
*(c + 1) = *(c + 1) - 1;
*(c + 1) -= 1;
break;
}
break;
@@ -703,7 +705,7 @@ void Helpers::CharToUpperUTF8(char * c) {
case 0x9B: //ś (0xC5,0x9B) -> Ś (0xC5,0x9A)
case 0xBA: //ź (0xC5,0xBA) -> Ź (0xC5,0xB9)
case 0xBC: //ż (0xC5,0xBC) -> Ż (0xC5,0xBB)
*(c + 1) = *(c + 1) - 1;
*(c + 1) -= 1;
break;
}
break;