X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fstringbuf.c;h=aadd92d1913ad957b2beb79cf2ccf3da2d69cb37;hb=d6a268eae59b4355daf9e5b32d097530e24566e7;hp=f3cd8c54364d289cc17a13f6637d900476c29630;hpb=53d9b46861650835b0994566a728c4ba3da8413a;p=citadel.git diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index f3cd8c543..aadd92d19 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -3328,14 +3328,16 @@ void StrBuf_RFC822_2_Utf8(StrBuf *Target, */ 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))