From: Kenichi Handa Date: Wed, 7 Feb 2001 04:24:49 +0000 (+0000) Subject: (parse_str_to_multibyte): New function. X-Git-Tag: emacs-pretest-21.0.98~121 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=740f080d0996dd1e5c4a6cccfd0c67b1a7a40f78;p=emacs.git (parse_str_to_multibyte): New function. --- diff --git a/src/charset.c b/src/charset.c index a7522c4cf4e..4bad7b5ab28 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1535,6 +1535,23 @@ str_as_multibyte (str, len, nbytes, nchars) return (to - str); } +/* Parse unibyte string at STR of LEN bytes, and return the number of + bytes it may ocupy when converted to multibyte string by + `str_to_multibyte'. */ + +int +parse_str_to_multibyte (str, len) + unsigned char *str; + int len; +{ + unsigned char *endp = str + len; + int bytes; + + for (bytes = 0; str < endp; str++) + bytes += (*str < 0x80 || *str >= 0xA0) ? 1 : 2; + return bytes; +} + /* Convert unibyte text at STR of NBYTES bytes to multibyte text that contains the same single-byte characters. It actually converts all 8-bit characters to multibyte forms. It is assured