// useful_mbtowc.h // PUBLIC DOMAIN // http:///www.purposeful.co.uk/software/yabaplib /* I, Tom Vajzovic, am the author of this software and its documentation. I permanently abandon all intellectual property rights in them, including copyright, trademarks, design rights, database right, patents, and the right to be identified as the author. I am fairly certain that the software does what the documentation says it does, but I do not guarantee that it does, or that it does what you think it should. I do not guarantee that it will not have undesirable side effects. You are free to use, modify and distribute this software as you please, but you do so at your own risk. If you do not pass on this warning then you may be responsible for any problems encountered by those who obtain the software through you. */ #include #include /* This is like mbrtowc, except that: Its return type is signed, so that error return values compare less than zero. If ps is null, an initial state is assumed on every call, not some hidden static state. If a null character is converted, the number of bytes that made it up is returned, not zero. If n bytes is not enough to make up a wide character then zero is returned, not (size_t)-2. */ ssize_t useful_mbtowc( wchar_t *pwc, const char *s, size_t n, mbstate_t *ps ); /* This is a replacement for mbsrtowcs. It reads up to n bytes from s, and writes up to nwc wide characters to pwc. As many as possibly characters will be converted; null bytes or null wide characters are not treated specially. It returns the number of wide characters written on success. If an illegal sequence is encountered it returns less than zero and errno is set to EILSEQ. If ps is not null, *ps provides the initial shift state and is updated to the final shift state. If ps is null, an initial state is assumed on every call, not some hidden static state. If endp is not null, *endp is updated to the first byte from s that was not part of the converted string, even on error. */ ssize_t useful_mbstowcs( wchar_t *pwc, size_t nwc, const char *s, size_t n, mbstate_t *ps, const char **endp );