mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-16 17:21:10 +00:00
fixed ibm437_to_utf8
This commit is contained in:
parent
0bf634013e
commit
c95d611c1f
2 changed files with 20 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue