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 <ctype.h>
    int isleadbyte( int ch );

Description:
    The isleadbyte function tests if the argument ch is a valid first byte
    of a multibyte character in the current code page.

    For example, in code page 932, a valid lead byte is any byte in the
    range 0x81 through 0x9F or 0xE0 through 0xFC.

Returns:
    The isleadbyte function returns a non-zero value when the argument is a
    valid lead byte.  Otherwise, zero is returned.

Example:
    #include <stdio.h>
    #include <ctype.h>
    #include <mbctype.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( char )

    void main()
      {
        int   i;

        _setmbcp( 932 );
        for( i = 0; i < SIZE; i++ ) {
          printf( "%2.2x is %sa valid lead byte\n",
                chars[i],
                ( isleadbyte( chars[i] ) ) ? "" : "not " );
        }
      }

    produces the following:

    20 is not a valid lead byte
    2e is not a valid lead byte
    31 is not a valid lead byte
    41 is not a valid lead byte
    81 is a valid lead byte
    40 is not a valid lead byte
    82 is a valid lead byte
    60 is not a valid lead byte
    82 is a valid lead byte
    a6 is not a valid lead byte
    83 is a valid lead byte
    42 is not a valid lead byte
    a1 is not a valid lead byte
    a6 is not a valid lead byte
    df is not a valid lead byte
    e0 is a valid lead byte
    a1 is not a valid lead byte
    00 is not a valid lead byte

Classification:
    WATCOM

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

See Also:
    isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct,
    isspace, isupper, iswctype, isxdigit, tolower, toupper

See Also: iswctype

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