Skip to content

Commit

Permalink
fixed ibm437_to_utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Dec 12, 2023
1 parent 0bf6340 commit c95d611
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/common/filesystem/source/unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}


}
2 changes: 1 addition & 1 deletion src/common/filesystem/source/unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

0 comments on commit c95d611

Please sign in to comment.