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 _mbclen( const unsigned char *ch );
    size_t far _fmbclen( const unsigned char __far *ch );

Description:
    The _mbclen function determines the number of bytes comprising the
    multibyte character pointed to by ch.

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

Returns:
    If ch is a NULL pointer, the _mbclen function returns zero if multibyte
    character encodings do not have state-dependent encoding, and non-zero
    otherwise.  If ch is not a NULL pointer, the _mbclen function returns:

    Value     Meaning

0
    if ch points to the null character

1
    if ch points to a single-byte character

2
    if ch points to a double-byte character

-1
    if ch does not point to a valid multibyte character



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

    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       /* null character */
    };

    void main()
      {
        int     i, j;

        _setmbcp( 932 );
        for( i = 0; i < sizeof(chars); i += j ) {
            j = _mbclen( &chars[i] );
            printf( "%d bytes in character\n", j );
        }
      }

    produces the following:

    1 bytes in character
    1 bytes in character
    1 bytes in character
    1 bytes in character
    2 bytes in character
    2 bytes in character
    2 bytes in character
    2 bytes in character
    1 bytes in character
    1 bytes in character
    1 bytes in character
    2 bytes in character
    1 bytes in character

Classification:
    WATCOM

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

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

See Also:
    _mbccmp, _mbccpy, _mbcicmp, _mbcjistojms, _mbcjmstojis, _mbctohira,
    _mbctokata, _mbctolower, _mbctombb, _mbctoupper, mblen, mbrlen, mbrtowc,
    mbsrtowcs, mbstowcs, mbtowc, sisinit, wcrtomb, wcsrtombs, wcstombs,
    wctob, wctomb

See Also: _mbcjistojms _mbcjmstojis

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