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 _mbsbtype( const unsigned char *mbstr, int count );
    int _fmbsbtype( const unsigned char __far *mbstr,
                    int count );

Description:
    The _mbsbtype function determines the type of a byte in a multibyte
    character string.  The function examines only the byte at offset count
    in mbstr, ignoring invalid characters before the specified byte

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

Returns:
    The _mbsbtype 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 a valid lead byte character (e.g., 0x81 - 0x9F,
        0xE0 - 0xFC in code page 932)

    _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 value except 0x20 -
        0x7E, 0xA1 - 0xDF, 0x81 - 0x9F, 0xE0 - 0xFC in code page 932)



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;

        _setmbcp( 932 );
        for( i = 0; i < SIZE; i++ )
          printf( "%s\n", types[ 1+_mbsbtype( chars, i ) ] );
      }

    produces the following:

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

Classification:
    WATCOM

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

    _fmbsbtype - 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, _mbbtype, _setmbcp

See Also: _getmbcp _ismbcalnum

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