#include <wchar.h>
|
size_t
mbsrtowcs (wchar_t * restrict dst, const char ** restrict src, size_t len, mbstate_t * restrict ps); |
size_t
mbsnrtowcs (wchar_t * restrict dst, const char ** restrict src, size_t nms, size_t len, mbstate_t * restrict ps); |
If dst is NULL, no characters are stored.
If dst is not NULL, the pointer pointed to by src is updated to point to the character after the one that conversion stopped at. If conversion stops because a null character is encountered, *src is set to NULL.
The mbstate_t argument, ps, is used to keep track of the shift state. If it is NULL, mbsrtowcs uses an internal, static mbstate_t object, which is initialized to the initial conversion state at program startup.
The mbsnrtowcs function behaves identically to mbsrtowcs, except that conversion stops after reading at most nms bytes from the buffer pointed to by src.
The behavior of the mbsrtowcs and mbsnrtowcs is affected by LC_CTYPE category of the current locale.
/* Illustrates how to use mbsrtowcs API */ #include <stdio.h> #include <stdlib.h> #include <wchar.h> size_t example_mbsrtowcs(wchar_t *wc, char *s, size_t n) { size_t len; mbstate_t mbs; /* converting multibyte string to a wide-char string */ len = mbsrtowcs(wc, &s, n, &mbs); /* checking for error */ if(len < 0) { wprintf(L"mbsrtowcs returned error!!\n"); } /* returning no of bytes consumed */ return (len); }
/* Illustrates how to use mbsrntowcs API */ #include <stdio.h> #include <stdlib.h> #include <wchar.h> size_t example_mbsnrtowcs(wchar_t *wc, char *s, size_t n, size_t nms) { size_t len; mbstate_t mbs; /* converting multibyte string to a wide-char string */ len = mbsnrtowcs(wc, &s, nms, n, &mbs); /* checking for error */ if(len < 0) { wprintf(L"mbsnrtowcs returned error!!\n"); } /* returning no of bytes consumed */ return (len); }
[EILSEQ] | |
An invalid multibyte character sequence was encountered. | |
[EINVAL] | |
The conversion state is invalid. | |
© 2005-2007 Nokia |