MBSTOWCS - convert multibyte char string to wide chars.

(ANSI Standard)


#include <stdlib.h>
length = mbstowcs(wcstring,mbstring,N);


wchar_t *wcstring;
points to an area of memory where "mbstowcs" can store the wide character string result. This must be large enough to hold up to N wide characters.
const char *mbstring;
points to a string of multibyte characters.
size_t N;
is the maximum number of multibyte characters to convert from "mbstring".
size_t length;
is the actual number of wide characters in the converted string.


The "mbstowcs" function converts multibyte characters from "mbstring" into wide characters, and stores the wide characters in the memory indicated by "wcstring". The multibyte string is assumed to begin in the initial shift state. Conversion stops when N wide characters have been stored or when "mbstowcs" converts a multibyte character into the null wide character (corresponding to '\0'). In this last case, the zero value will be stored in the wide character string (marking its end).

If "mbstowcs" encounters an invalid multibyte character as it is performing the conversions, it returns -1 cast to size_t. Otherwise, it returns the number of multibyte characters converted, not counting a final zero value (if one was found).

If "mbstring" overlaps "wcstring", the behavior is undefined.

See Also:

expl c lib mbtowc

expl c lib wcstombs

expl c lib wctomb

Copyright © 1996, Thinkage Ltd.