fixed ibm437_to_utf8

This commit is contained in:
Christoph Oelckers 2023-12-11 07:34:56 +01:00
parent 0bf634013e
commit c95d611c1f
2 changed files with 20 additions and 2 deletions

View File

@ -121,7 +121,7 @@ void ibm437_to_utf8(const char* in, std::vector<char>& buffer)
while (int char1 = (uint8_t)*in++)
{
if (char1 >= 0x80) char1 = ibm437map[char1];
if (char1 >= 0x80) char1 = ibm437map[char1 - 0x80];
utf8_encode(char1, buffer);
}
buffer.push_back(0);
@ -140,4 +140,22 @@ char *tolower_normalize(const char *str)
return (char*)retval;
}
//==========================================================================
//
// validates the string for proper UTF-8
//
//==========================================================================
bool unicode_validate(const char* str)
{
while (*str != 0)
{
int cp;
int result = utf8proc_iterate((const uint8_t*)str, -1, &cp);
if (result < 0) return false;
}
return true;
}
}

View File

@ -6,7 +6,7 @@ namespace FileSys {
void utf16_to_utf8(const unsigned short* in, std::vector<char>& buffer);
void ibm437_to_utf8(const char* in, std::vector<char>& buffer);
int unicode_tolower(int c);
char *tolower_normalize(const char *str);
bool unicode_validate(const char* str);
}