(ANSI Standard)
#include <stdlib.h> length = mbstowcs(wcstring,mbstring,N);
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".
Copyright © 1996, Thinkage Ltd.