* UTF8ToCharCode() only skipped 3 bytes for a 4 byte character.

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18702 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-08-29 22:20:18 +00:00
parent 641309e8d0
commit e04ec8626e
+8 -6
View File
@@ -12,7 +12,7 @@
static inline bool static inline bool
IsInsideGlyph(uchar ch) IsInsideGlyph(uchar ch)
{ {
return (ch & 0xC0) == 0x80; return (ch & 0xc0) == 0x80;
} }
static inline uint32 static inline uint32
@@ -104,12 +104,13 @@ UTF8CountChars(const char *text, int32 numBytes)
} }
/* UTF8ToCharCode converts the input that includes potential multibyte chars /*! UTF8ToCharCode converts the input that includes potential multibyte chars
to UTF-32 char codes that can be used by FreeType. The string pointer is to UTF-32 char codes that can be used by FreeType. The string pointer is
then advanced to the next character in the string. In case the terminating then advanced to the next character in the string. In case the terminating
0 is reached, the string pointer is not advanced anymore and spaces are 0 is reached, the string pointer is not advanced anymore and spaces are
returned. This makes it safe to overruns and enables streamed processing returned. This makes it safe to overruns and enables streamed processing
of UTF8 strings. */ of UTF8 strings.
*/
static inline uint32 static inline uint32
UTF8ToCharCode(const char **bytes) UTF8ToCharCode(const char **bytes)
{ {
@@ -135,7 +136,7 @@ UTF8ToCharCode(const char **bytes)
result += (*bytes)[2] & 0x3f; result += (*bytes)[2] & 0x3f;
result <<= 6; result <<= 6;
result += (*bytes)[3] & 0x3f; result += (*bytes)[3] & 0x3f;
(*bytes) += 3; (*bytes) += 4;
return result; return result;
} }
@@ -175,8 +176,9 @@ UTF8ToCharCode(const char **bytes)
} }
/* UTF8ToLength works like strlen() but takes UTF8 encoded multibyte chars /*! UTF8ToLength works like strlen() but takes UTF8 encoded multibyte chars
into account. It's a quicker version of UTF8CountChars above. */ into account. It's a quicker version of UTF8CountChars above.
*/
static inline int32 static inline int32
UTF8ToLength(const char *bytes) UTF8ToLength(const char *bytes)
{ {