Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    size_t mbstowcs( wchar_t *pwcs, const char *s, size_t n );

Description:
    The mbstowcs function converts a sequence of multibyte characters
    pointed to by s into their corresponding wide character codes and stores
    not more than n codes into the array pointed to by pwcs.  The mbstowcs
    function does not convert any multibyte characters beyond the null
    character.  At most n elements of the array pointed to by pwcs will be
    modified.

Returns:
    If an invalid multibyte character is encountered, the mbstowcs function
    returns (size_t)-1.  Otherwise, the mbstowcs function returns the number
    of array elements modified, not including the terminating zero code if
    present.

See Also:
    mblen, mbtowc, wctomb, wcstombs

Example:
    #include <stdio.h>
    #include <stdlib.h>

    void main()
      {
        char    *wc = "string";
        wchar_t wbuffer[50];
        int     i, len;

        len = mbstowcs( wbuffer, wc, 50 );
        if( len != -1 ) {
          wbuffer[len] = '\0';
          printf( "%s(%d)\n", wc, len );
          for( i = 0; i < len; i++ )
            printf( "/%4.4x", wbuffer[i] );
          printf( "\n" );
        }
      }

    produces the following:

    string(6)
    /0073/0074/0072/0069/006e/0067

Classification:
    ANSI

Systems:
    All

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson