Bruno Haible wrote on 2001-05-28 14:20 UTC:
> Edmund GRIMLEY EVANS writes:
>
> > With glibc-2.2.3, mbrtowc(&wc, "", 0, &ps) seems to return 0 instead
> > of (size_t)(-2). I think this is a bug.
>
> It's my interpretation of the ISO C 99 standard that the return value
> should be (size_t)(-2). But I agree with Markus that it's a borderline
> that you should avoid.
[#4] The mbrtowc function returns the first of the following
that applies (given the current conversion state):
0 if the next n or fewer bytes complete the
multibyte character that corresponds to the
null wide character (which is the value
stored).
positive if the next n or fewer bytes complete a
valid multibyte character (which is the
value stored); the value returned is the
number of bytes that complete the multibyte
character.
(size_t)(-2) if the next n bytes contribute to an
incomplete (but potentially valid) multibyte
character, and all n bytes have been
processed (no value is stored).291)
(size_t)(-1) if an encoding error occurs, in which case
the next n or fewer bytes do not contribute
to a complete and valid multibyte character
(no value is stored); the value of the macro
EILSEQ is stored in errno, and the
conversion state is unspecified.
"if the next n bytes contribute"
The philosophical question is, whether 0 bytes "contribute".
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/