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 wcstombs( char *s, const wchar_t *pwcs, size_t n );
    #include <mbstring.h>
    size_t _fwcstombs( char __far *s,
                       const wchar_t __far *pwcs,
                       size_t n );

Description:
    The wcstombs function converts a sequence of wide character codes from
    the array pointed to by pwcs into a sequence of multibyte characters and
    stores them in the array pointed to by s.  The wcstombs function stops
    if a multibyte character would exceed the limit of n total bytes, or if
    the null character is stored.  At most n bytes of the array pointed to
    by s will be modified.

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

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

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

    wchar_t wbuffer[] = {
        0x0073,
        0x0074,
        0x0072,
        0x0069,
        0x006e,
        0x0067,
        0x0000
      };

    void main()
      {
        char    mbsbuffer[50];
        int     i, len;

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

    produces the following:

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

Classification:
    wcstombs is ANSI, _fwcstombs is not ANSI, wcstombs is ANSI

Systems:
     wcstombs - All, Netware

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

See Also:
    mblen, mbtowc, mbstowcs, wctomb

See Also:

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