Markus Kuhn wrote:
> [...] You should never call mbrtowc with 0 as
> the number n of bytes that mbrtowc is allowed to examine at 
> most. Such a call seems useless, and the standard does not
> define the behaviour of mbrtowc in that case.
> [...]
> people try to initialize an mb_state variable with a call
> to mbrtowc(NULL, "", 1, &ps). Instead, the correct (though
> at first glance ugly) initialization is memset(&ps, 0,
> sizeof(ps)).

Anyone knows any reliable on-line reference for these functions? Or,
alternatively, how can I purchase a copy of "ISO/IEC 9899:1999(E)" that
Markus mentioned?

So far, I have been using <http://www.dinkumware.com/htm_cl/wchar.html>,
mainly because I trust the good reputation of the co-author P.J. Plauger.

However, this is a *commercial* reference to a *commercial* implementation,
so it is neither correct nor portable to rely on it.

BTW, I see that Plauger's reference contradicts what Markus said in two
points, and I have no way of determining who is more correct or up to date:

1) In <http://www.dinkumware.com/htm_cl/wchar.html#mbrtowc>, it says that
mbrtowc() return zero only when "the next completed character is a null
character", which cannot of course be the case when the size is zero.
Plauger too does not specify what the function should return in this case,
but -2 ("incomplete mb character") seems a reasonable choice.

2) In <http://www.dinkumware.com/htm_cl/wchar.html#mbstate_t> it says that
mbstate_t can be initialized simply by setting its *first* member of  to
zero ("mbstate_t mbst = {0};"), and this would imply that a memset() is only
needed to *re*initialize it.

Thanks.
_ Marco Cimarosti
-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to