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 *_mbsnbcat( unsigned char *dst,
                        const unsigned char *src,
                                     size_t n );
    unsigned char __far *_fmbsnbcat( unsigned char __far *dst,
                               const unsigned char __far *src,
                                                  size_t n );

Description:
    The _mbsnbcat function appends not more than n bytes of the string
    pointed to by src to the end of the string pointed to by dst.  If the
    byte immediately preceding the null character in dst is a lead byte, the
    initial byte of src overwrites this lead byte.  Otherwise, the initial
    byte of src overwrites the terminating null character at the end of dst.
     If the last byte to be copied from src is a lead byte, the lead byte is
    not copied and a null character replaces it in dst.  In any case, a
    terminating null character is always appended to the result.

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

Returns:
    The _mbsnbcat function returns the value of dst.

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

    const unsigned char str1[] = {
        0x81,0x40, /* double-byte space */
        0x82,0x60, /* double-byte A */
        0x00
    };

    const unsigned char str2[] = {
        0x81,0x40, /* double-byte space */
        0x82,0xA6, /* double-byte Hiragana */
        0x83,0x42, /* double-byte Katakana */
        0x00
    };

    void main()
      {
        unsigned char   big_string[10];
        int             i;

        _setmbcp( 932 );
        memset( (char *) big_string, 0xee, 10 );
        big_string[9] = 0x00;
        printf( "Length of string = %d\n",
                strlen( (char *) big_string ) );
        for( i = 0; i < 10; i++ )
            printf( "%2.2x ", big_string[i] );
        printf( "\n" );

        _mbsnset( big_string, 0x8145, 5 );
        for( i = 0; i < 10; i++ )
            printf( "%2.2x ", big_string[i] );
        printf( "\n" );

        big_string[0] = 0x00;
        _mbsnbcat( big_string, str1, 3 );
        for( i = 0; i < 10; i++ )
            printf( "%2.2x ", big_string[i] );
        printf( "\n" );

        big_string[2] = 0x84;
        big_string[3] = 0x00;
        for( i = 0; i < 10; i++ )
            printf( "%2.2x ", big_string[i] );
        printf( "\n" );

        _mbsnbcat( big_string, str2, 5 );
        for( i = 0; i < 10; i++ )
            printf( "%2.2x ", big_string[i] );
        printf( "\n" );

      }

    produces the following:

    Length of string = 9
    ee ee ee ee ee ee ee ee ee 00
    81 45 81 45 81 45 81 45 20 00
    81 40 00 00 81 45 81 45 20 00
    81 40 84 00 81 45 81 45 20 00
    81 40 81 40 82 a6 00 00 20 00

Classification:
    WATCOM

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

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

See Also:
    _mbsnbcmp, _mbsnbcpy, _mbsnbset, _mbsnccnt, strncat, strcat

See Also:

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