From 25e8693c53d5e64194b06ebd62c775450bee0bc2 Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 22 Sep 2004 00:07:43 +0000 Subject: [PATCH] (count_utf_16_chars): Count each code of invalid surrogates as one. --- src/mtext.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mtext.c b/src/mtext.c index f34586f..7f17852 100644 --- a/src/mtext.c +++ b/src/mtext.c @@ -449,22 +449,18 @@ count_utf_16_chars (const void *data, int nitems, int swap) if (prev_surrogate) { if (c < 0xDC00 || c >= 0xE000) - return -1; - prev_surrogate = 0; + /* Invalid surrogate */ + nchars++; } else { - if (c < 0xD800) - ; - else if (c < 0xDC00) + if (c >= 0xD800 && c < 0xDC00) prev_surrogate = 1; - else if (c < 0xE000) - return -1; nchars++; } } if (prev_surrogate) - return -1; + nchars++; return nchars; } -- 1.7.10.4