X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fstringbuf.c;h=8718ec065a68ac6e38913def4fc30a84226c75da;hb=6d77e7946f7f1143c8ce75f9cbf2f6ddbab5e57a;hp=4a0953f9a6440c544367eacf803cfd7b56299409;hpb=e395ebd37ccd1ff4af1f6878465852bcffb24e46;p=citadel.git diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 4a0953f9a..8718ec065 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -3176,14 +3176,16 @@ void StrBuf_RFC822_to_Utf8(StrBuf *Target, const StrBuf *DecodeMe, const StrBuf* */ static inline int Ctdl_GetUtf8SequenceLength(const char *CharS, const char *CharE) { - int n = 1; - char test = (1<<7); + int n = 0; + unsigned char test = (1<<7); if ((*CharS & 0xC0) == 0) return 1; - while ((n < 8) && ((test & *CharS) != 0)) { - test = test << 1; + while ((n < 8) && + ((test & ((unsigned char)*CharS)) != 0)) + { + test = test >> 1; n ++; } if ((n > 6) || ((CharE - CharS) < n))