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 <mbstring.h>
    unsigned char *_mbsnbcpy( unsigned char *dst,
                        const unsigned char *src,
                        size_t n );
    unsigned char __far *_fmbsnbcpy( unsigned char __far *dst,
                               const unsigned char __far *src,
                               size_t n );

Description:
    The _mbsnbcpy function copies no more than n bytes from the string
    pointed to by src into the array pointed to by dst.  Copying of
    overlapping objects is not guaranteed to work properly.

    If the string pointed to by src is shorter than n bytes, null characters
    are appended to the copy in the array pointed to by dst, until n bytes
    in all have been written.  If the string pointed to by src is longer
    than n characters, then the result will not be terminated by a null
    character.

    The function is a data model independent form of the _mbsnbcpy function.
     It accepts far pointer arguments and returns a far pointer.  It is most
    useful in mixed memory model applications.

Returns:
    The _mbsnbcpy function returns the value of dst.

Example:
    #include <stdio.h>
    #include <mbctype.h>
    #include <mbstring.h>

    const unsigned char chars[] = {
        ' ',
        '.',
        '1',
        'A',
        0x81,0x40, /* double-byte space */
        0x82,0x60, /* double-byte A */
        0x82,0xA6, /* double-byte Hiragana */
        0x83,0x42, /* double-byte Katakana */
        0xA1,      /* single-byte Katakana punctuation */
        0xA6,      /* single-byte Katakana alphabetic */
        0xDF,      /* single-byte Katakana alphabetic */
        0xE0,0xA1, /* double-byte Kanji */
        0x00
    };

    void main()
      {
        unsigned char   chars2[20];
        int             i;

        _setmbcp( 932 );
        _mbsnset( chars2, 0xFF, 20 );
        _mbsnbcpy( chars2, chars, 11 );
        for( i = 0; i < 20; i++ )
            printf( "%2.2x ", chars2[i] );
        printf( "\n" );
        _mbsnbcpy( chars2, chars, 20 );
        for( i = 0; i < 20; i++ )
            printf( "%2.2x ", chars2[i] );
        printf( "\n" );
      }

    produces the following:

    20 2e 31 41 81 40 82 60 82 a6 83 ff ff ff ff ff ff ff ff ff
    20 2e 31 41 81 40 82 60 82 a6 83 42 a1 a6 df e0 a1 00 00 00

Classification:
    WATCOM

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

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

See Also:
    strcpy, strdup

See Also:

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