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 Library Reference - <u>synopsis:</u> 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 );
    #include <mbstring.h>
    size_t _fmbstowcs( const wchar_t __far *pwcs,
                       char __far *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.

    The _fmbstowcs function is a data model independent form of the mbstowcs
    function that accepts far pointer arguments.  It is most useful in mixed
    memory model applications.

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.

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:
    mbstowcs is ANSI, _fmbstowcs is not ANSI

Systems:
     mbstowcs - All, Netware

    _fmbstowcs - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    mblen, mbtowc, wctomb, wcstombs

See Also:

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