Fixed invalid UTF-8 sequences being generated by wstring_to_utf8,

causing display bugs with some accented characters on some platforms.
Changed portable_isspace() so it only returns true on ASCII spaces.
This commit is contained in:
Philippe Plantier 2004-05-24 21:13:28 +00:00
parent 10992d045a
commit 444dc086e4
2 changed files with 4 additions and 0 deletions

View File

@ -43,6 +43,9 @@ bool isnewline(char c)
//and they will work, by making sure the definition of whitespace is consistent
bool portable_isspace(char c)
{
// returns true only on ASCII spaces
if((unsigned char)c >= 128)
return false;
return isnewline(c) || isspace(c);
}

View File

@ -210,6 +210,7 @@ std::string wstring_to_utf8(const wide_string &src)
} else {
for(j = count-1; j >= 0; --j) {
unsigned char c = (ch >> (6*j)) & 0x3f;
c |= 0x80;
if(j == count-1)
c |= 0xff << (8 - count);
push_back(ret,c);