Merge pull request #670 from emminizer/four-byte-utf8

osgText::String:createUTF8EncodedString() now supports 4-byte UTF-8 strings (code points over 0x100000)
This commit is contained in:
OpenSceneGraph git repository
2018-12-07 14:53:52 +00:00
committed by GitHub

View File

@@ -312,12 +312,19 @@ std::string String::createUTF8EncodedString() const
utf8string+=(char)(0xc0 | (currentChar>>6));
utf8string+=(char)(0x80 | (currentChar & 0x3f));
}
else
else if (currentChar < 0x10000)
{
utf8string+=(char)(0xe0 | (currentChar>>12));
utf8string+=(char)(0x80 | ((currentChar>>6) & 0x3f));
utf8string+=(char)(0x80 | (currentChar & 0x3f));
}
else
{
utf8string+=(char)(0xf0 | (currentChar >> 18));
utf8string+=(char)(0x80 | ((currentChar >> 12) & 0x3f));
utf8string+=(char)(0x80 | ((currentChar >> 6) & 0x3f));
utf8string+=(char)(0x80 | (currentChar & 0x3f));
}
}
return utf8string;
}