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 <wchar.h>
    int sisinit( const mbstate_t *ps );

Description:
    If ps is not a null pointer, the sisinit function determines whether the
    pointed-to  mbstate_t object describes an initial conversion state.

Returns:
    The sisinit function returns nonzero if ps is a null pointer or if the
    pointed-to object describes an initial conversion state; otherwise, it
    returns zero.


Example:
    #include <stdio.h>
    #include <wchar.h>
    #include <mbctype.h>
    #include <errno.h>


    const 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()
      {
        int         i, j, k;
        wchar_t     pwc;
        mbstate_t   pstate = { 0 };

        _setmbcp( 932 );
        j = 1;
        for( i = 0; j > 0; i += j ) {
          printf( "We are %sin an initial conversion state\n",
                  sisinit( &pstate ) ? "not " : "" );
          j = mbrtowc( &pwc, &chars[i], MB_CUR_MAX, &pstate );
          printf( "%d bytes in character ", j );
          if( errno == EILSEQ ) {
            printf( " - illegal multibyte character\n" );
          } else {
            if( j == 0 ) {
              k = 0;
            } else if ( j == 1 ) {
              k = chars[i];
            } else if( j == 2 ) {
              k = chars[i]<<8 | chars[i+1];
            }
            printf( "(%#6.4x->%#6.4x)\n", k, pwc );
          }
        }
      }

    produces the following:

    We are in an initial conversion state
    1 bytes in character (0x0020->0x0020)
    We are in an initial conversion state
    1 bytes in character (0x002e->0x002e)
    We are in an initial conversion state
    1 bytes in character (0x0031->0x0031)
    We are in an initial conversion state
    1 bytes in character (0x0041->0x0041)
    We are in an initial conversion state
    2 bytes in character (0x8140->0x3000)
    We are in an initial conversion state
    2 bytes in character (0x8260->0xff21)
    We are in an initial conversion state
    2 bytes in character (0x82a6->0x3048)
    We are in an initial conversion state
    2 bytes in character (0x8342->0x30a3)
    We are in an initial conversion state
    1 bytes in character (0x00a1->0xff61)
    We are in an initial conversion state
    1 bytes in character (0x00a6->0xff66)
    We are in an initial conversion state
    1 bytes in character (0x00df->0xff9f)
    We are in an initial conversion state
    2 bytes in character (0xe0a1->0x720d)
    We are in an initial conversion state
    0 bytes in character (  0000->  0000)

Classification:
    ANSI

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

See Also:
    _mbccmp, _mbccpy, _mbcicmp, _mbcjistojms, _mbcjmstojis, _mbclen,
    _mbctohira, _mbctokata, _mbctolower, _mbctombb, _mbctoupper, mblen,
    mbrlen, mbrtowc, mbsrtowcs, mbstowcs, mbtowc, 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