From 5ceb0ce4070c1058239e81f9edfd37f5c9358c6a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 8 Feb 2011 13:22:10 +0000 Subject: [PATCH] Evas encoding: Improved evas_common_encoding_utf8_get_len to be more consistent with evas_common_encoding_utf8_get_next. This is a semi fix to the issue with malformed utf8 strings (#670) SVN revision: 56806 --- legacy/evas/src/lib/engines/common/evas_encoding.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_encoding.c b/legacy/evas/src/lib/engines/common/evas_encoding.c index 2d2a842921..96a269024b 100644 --- a/legacy/evas/src/lib/engines/common/evas_encoding.c +++ b/legacy/evas/src/lib/engines/common/evas_encoding.c @@ -236,14 +236,11 @@ EAPI int evas_common_encoding_utf8_get_len(const char *buf) { /* returns the number of utf8 characters (not bytes) in the string */ - int index = 0, len = 0; + int i = 0, len = 0; + + while (evas_common_encoding_utf8_get_next(buf, &i)) + len++; - while (buf[index]) - { - if ((buf[index] & 0xc0) != 0x80) - len++; - index++; - } return len; }