From fc422d1cda0607f0c8cd7bb25baabd63354475d3 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 19 Aug 2011 17:12:32 +0000 Subject: [PATCH] Fix detecting of UTF8 Sequences - we need to exactly check for both highest bits to be set, not one of them. --- libcitadel/lib/stringbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 55daf6192..2e91d50f1 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -3315,7 +3315,7 @@ static inline int Ctdl_GetUtf8SequenceLength(const char *CharS, const char *Char int n = 0; unsigned char test = (1<<7); - if ((*CharS & 0xC0) == 0) + if ((*CharS & 0xC0) != 0xC0) return 1; while ((n < 8) && @@ -3338,7 +3338,7 @@ static inline int Ctdl_GetUtf8SequenceLength(const char *CharS, const char *Char static inline int Ctdl_IsUtf8SequenceStart(const char Char) { /** 11??.???? indicates an UTF8 Sequence. */ - return ((Char & 0xC0) != 0); + return ((Char & 0xC0) == 0xC0); } /** -- 2.30.2