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>
Sat, 20 Aug 2011 12:08:44 +0000 (12:08 +0000)
  - we need to exactly check for both highest bits to be set, not one of them.

libcitadel/lib/stringbuf.c

index 86ce299d993e93a97ddc694fcc248b49f7b36024..9d9d2ebf1bb410333fe9f9e264e057388fa05d82 100644 (file)
@@ -3184,7 +3184,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) && 
@@ -3207,7 +3207,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);
 }
 
 /**