Fix detecting of UTF8 Sequences
authorWilfried Goesgens <dothebart@citadel.org>
Fri, 19 Aug 2011 17:12:32 +0000 (17:12 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Fri, 19 Aug 2011 17:15:35 +0000 (17:15 +0000)
  - we need to exactly check for both highest bits to be set, not one of them.

libcitadel/lib/stringbuf.c

index 55daf6192c57b9127e1735b71a947ea9772804dd..2e91d50f1b998c7e0a1cfdc3c97d5ec1e72b966f 100644 (file)
@@ -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);
 }
 
 /**