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:
    #ninclude <tchar.h>
    char *_strninc( const char *str, size_t count );
    wchar_t *_wcsninc( const wchar_t *str, size_t count );
    #ninclude <mbstring.h>
    unsigned char *_mbsninc( const unsigned char *str,
                             size_t count );
    unsigned char __far *_fmbsninc(
                            const unsigned char __far *str,
                            size_t count );

Description:
    The _mbsninc function increments str by count multibyte characters.
     _mbsninc recognizes multibyte-character sequences according to the
    multibyte code page currently in use.  The header file <tchar.h> defines
    the generic-text routine  _tcsninc.  This macro maps to _mbsninc if
     _MBCS has been defined, or to _wcsninc if  _UNICODE has been defined.
     Otherwise  _tcsninc maps to _strninc.  _strninc and _wcsninc are
    single-byte-character string and wide-character string versions of
    _mbsninc.  _wcsninc and _strninc are provided only for this mapping and
    should not be used otherwise.

Returns:
    The _strninc function returns a pointer to str after it has been
    incremented by count characters or  NULL if str was  NULL.  If count
    exceeds the number of characters remaining in the string, the result is
    undefined.

Example:
    #ninclude <stdio.h>
    #ninclude <mbctype.h>
    #ninclude <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
    };

    #define SIZE sizeof( chars ) / sizeof( unsigned char )

    void main()
      {
        int                 j, k;
        const unsigned char *next;

        _setmbcp( 932 );
        next = chars;
        do {
          next = _mbsninc( next, 1 );
          j = mblen( next, MB_CUR_MAX );
          if( j == 0 ) {
            k = 0;
          } else if ( j == 1 ) {
            k = *next;
          } else if( j == 2 ) {
            k = *(next)<<8 | *(next+1);
          }
          printf( "Next character %#6.4x\n", k );
        } while( next != &chars[ SIZE - 1 ] );
      }

    produces the following:

    Next character 0x002e
    Next character 0x0031
    Next character 0x0041
    Next character 0x8140
    Next character 0x8260
    Next character 0x82a6
    Next character 0x8342
    Next character 0x00a1
    Next character 0x00a6
    Next character 0x00df
    Next character 0xe0a1
    Next character   0000

Classification:
    WATCOM

Systems:
     _strninc - MACRO

    _wcsninc - MACRO
    _mbsninc - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32
    _fmbsninc - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    _strdec, _strinc

See Also:

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