MBSTOWCS - convert multibyte char string to wide chars.

(ANSI Standard)

Usage:

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

Where:

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.

Description:

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.

NOTE: This version of C only supports single byte characters, and wide characters are one byte long. Therefore, "mbstowcs" is much like "strncpy".

See Also:

expl c lib wcstombs

Copyright © 1996, Thinkage Ltd.