mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-11 18:29:52 +03:00
Fix first letter not capitalized in Polish
This commit is contained in:
@@ -678,6 +678,41 @@ std::string Helpers::toUpper(std::string const & s) {
|
||||
return lc;
|
||||
}
|
||||
|
||||
// capitalizes one UTF-8 character in char array
|
||||
// works with Latin1 (1 byte) and Polish (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;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0xC5:
|
||||
switch (*(c + 1)) {
|
||||
case 0x82: //ł (0xC5,0x82) -> Ł (0xC5,0x81)
|
||||
case 0x84: //ń (0xC5,0x84) -> Ń (0xC5,0x83)
|
||||
case 0x9B: //ś (0xC5,0x9B) -> Ś (0xC5,0x9A)
|
||||
case 0xBA: //ź (0xC5,0xBA) -> Ź (0xC5,0xB9)
|
||||
case 0xBC: //ż (0xC5,0xBC) -> Ż (0xC5,0xBB)
|
||||
*(c + 1) = *(c + 1) - 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
*c = toupper(*c); //works on Latin1 letters
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// replace char in char string
|
||||
void Helpers::replace_char(char * str, char find, char replace) {
|
||||
if (str == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user