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>
    #include <mbctype.h> (for manifest constants)
    int _mbbtype( unsigned char ch, int type );

Description:
    The _mbbtype function determines the type of a byte in a multibyte
    character.  If the value of type is any value except 1, _mbbtype tests
    for a valid single-byte or lead byte of a multibyte character.  If the
    value of type is 1, _mbbtype tests for a valid trail byte of a multibyte
    character.

    Note:  A similar function was called  chkctype in earlier versions.

Returns:
    If the value of type is not 1, the _mbbtype function returns one of the
    following values:

    _MBC_SINGLE
        the character is a valid single-byte character (e.g., 0x20 - 0x7E,
        0xA1 - 0xDF in code page 932)

    _MBC_LEAD
        the character is valid lead byte character (e.g., 0x81 - 0x9F, 0xE0
        - 0xFC in code page 932)

    _MBC_ILLEGAL
        the character is an illegal character (e.g., any value except 0x20 -
        0x7E, 0xA1 - 0xDF, 0x81 - 0x9F, 0xE0 - 0xFC in code page 932)

    If the value of type is 1, the _mbbtype function returns one of the
    following values:

    _MBC_TRAIL
        the character is a valid trailing byte character (e.g., 0x40 - 0x7E,
        0x80 - 0xFC in code page 932)

    _MBC_ILLEGAL
        the character is an illegal character (e.g., any character except a
        valid trailing byte character)



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

    const char *types[4] = {
        "ILLEGAL",
        "SINGLE",
        "LEAD",
        "TRAIL"
    };

    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     i, j, k;

        _setmbcp( 932 );
        k = 0;
        for( i = 0; i < SIZE; i++ ) {
          j = _mbbtype( chars[i], k );
          printf( "%s\n", types[ 1 + j ] );
          if( j == _MBC_LEAD )
            k = 1;
          else
            k = 0;
        }
      }

    produces the following:

    SINGLE
    SINGLE
    SINGLE
    SINGLE
    LEAD
    TRAIL
    LEAD
    TRAIL
    LEAD
    TRAIL
    LEAD
    TRAIL
    SINGLE
    SINGLE
    SINGLE
    LEAD
    TRAIL
    ILLEGAL

Classification:
    WATCOM

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

See Also:
    _getmbcp, _ismbcalnum, _ismbcalpha, _ismbccntrl, _ismbcdigit,
    _ismbcgraph, _ismbchira, _ismbckata, _ismbcl0, _ismbcl1, _ismbcl2,
    _ismbclegal, _ismbclower, _ismbcprint, _ismbcpunct, _ismbcspace,
    _ismbcsymbol, _ismbcupper, _ismbcxdigit, _setmbcp

See Also: _getmbcp _ismbcalnum

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