From 3a3ddfce492071e1b0f1d554fb83096c98bed79d Mon Sep 17 00:00:00 2001 From: Daniel Emminizer Date: Thu, 6 Dec 2018 14:07:55 -0500 Subject: [PATCH] osgText::String:createUTF8EncodedString() now supports 4-byte UTF-8 strings (code points over 0x100000). --- src/osgText/String.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/osgText/String.cpp b/src/osgText/String.cpp index fc181dc9e..18529998c 100644 --- a/src/osgText/String.cpp +++ b/src/osgText/String.cpp @@ -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; }