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>
    size_t _mbsnbcnt( const unsigned char *string, size_t n );
    size_t _fmbsnbcnt( const unsigned char __far *string,
                       size_t n );
    #include <tchar.h>
    size_t _strncnt( const char *string, size_t n );
    size_t _wcsncnt( const wchar_t *string, size_t n ) {

Description:
    The _mbsnbcnt function counts the number of bytes in the first n
    multibyte characters of the string string.

    Note:  This function was called  mtob in earlier versions.

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

    The header file <tchar.h> defines the generic-text routine  _tcsnbcnt.
     This macro maps to _mbsnbcnt if  _MBCS has been defined, or to the
    _wcsncnt macro if  _UNICODE has been defined.  Otherwise  _tcsnbcnt maps
    to _strncnt.  _strncnt and _wcsncnt are single-byte character string and
    wide-character string versions of _mbsnbcnt.  The _strncnt and _wcsncnt
    macros are provided only for this mapping and should not be used
    otherwise.

    The _strncnt function returns the number of characters (i.e., n) in the
    first n bytes of the single-byte string string.  The _wcsncnt function
    returns the number of bytes (i.e., 2 * n) in the first n wide characters
    of the wide-character string string.

Returns:
    The _strncnt functions return the number of bytes in the string up to
    the specified number of characters or until a null character is
    encountered.  The null character is not included in the count.  If the
    character preceding the null character was a lead byte, the lead byte is
    not included in the count.

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()
      {
        _setmbcp( 932 );
        printf( "%d bytes found\n",
                _mbsnbcnt( chars, 10 ) );
      }

    produces the following:

    14 bytes found

Classification:
    WATCOM

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

    _fmbsnbcnt - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32
    _strncnt - MACRO
    _wcsncnt - MACRO

See Also:
    _mbsnbcat, _mbsnbcnt, _mbsnccnt

See Also:

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