diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/text.cpp | 30 | ||||
-rw-r--r-- | engines/zvision/text.h | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp index e96bf4b32c..2fdfafcdf6 100644 --- a/engines/zvision/text.cpp +++ b/engines/zvision/text.cpp @@ -515,5 +515,35 @@ Common::String readWideLine(Common::SeekableReadStream &stream) { return asciiString; } +int8 getUtf8CharSize(char chr) { + if ((chr & 0x80) == 0) + return 1; + else if ((chr & 0xE0) == 0xC0) + return 2; + else if ((chr & 0xF0) == 0xE0) + return 3; + else if ((chr & 0xF8) == 0xF0) + return 4; + else if ((chr & 0xFC) == 0xF8) + return 5; + else if ((chr & 0xFE) == 0xFC) + return 6; + + return 1; +} + +uint16 readUtf8Char(const char *chr) { + uint16 result = 0; + if ((chr[0] & 0x80) == 0) + result = chr[0]; + else if ((chr[0] & 0xE0) == 0xC0) + result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F); + else if ((chr[0] & 0xF0) == 0xE0) + result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F); + else + result = chr[0]; + + return result; +} } // End of namespace ZVision diff --git a/engines/zvision/text.h b/engines/zvision/text.h index 6937832335..c1dc0c167c 100644 --- a/engines/zvision/text.h +++ b/engines/zvision/text.h @@ -92,6 +92,8 @@ private: }; Common::String readWideLine(Common::SeekableReadStream &stream); +int8 getUtf8CharSize(char chr); +uint16 readUtf8Char(const char *chr); } // End of namespace ZVision |