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 <tchar.h>
    char *_strdec( const char *start, const char *current );
    wchar_t *_wcsdec( const wchar_t *start,
                      const wchar_t *current );
    #include <mbstring.h>
    unsigned char *_mbsdec( const unsigned char *start,
                            const unsigned char *current );
    unsigned char *_fmbsdec( const unsigned char __far *start,
                         const unsigned char __far *current );

Description:
    The _strdec function returns a pointer to the previous character
    (single-byte, wide, or multibyte) in the string pointed to by start
    which must precede current.  The current character in the string is
    pointed to by current.  You must ensure that current does not point into
    the middle of a multibyte or wide character.

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

    The _wcsdec function is a wide-character version of _strdec that
    operates with wide-character strings.

    The _mbsdec function is a multibyte character version of _strdec that
    operates with multibyte character strings.

Returns:
    The _strdec function returns a pointer to the previous character
    (single-byte, wide, or multibyte depending on the function used).

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

    void main()
      {
        int                 j, k;
        const unsigned char *prev;

        _setmbcp( 932 );
        prev = &chars[ SIZE - 1 ];
        do {
          prev = _mbsdec( chars, prev );
          j = mblen( prev, MB_CUR_MAX );
          if( j == 0 ) {
            k = 0;
          } else if ( j == 1 ) {
            k = *prev;
          } else if( j == 2 ) {
            k = *(prev)<<8 | *(prev+1);
          }
          printf( "Previous character %#6.4x\n", k );
        } while( prev != chars );
      }

    produces the following:

    Previous character 0xe0a1
    Previous character 0x00df
    Previous character 0x00a6
    Previous character 0x00a1
    Previous character 0x8342
    Previous character 0x82a6
    Previous character 0x8260
    Previous character 0x8140
    Previous character 0x0041
    Previous character 0x0031
    Previous character 0x002e
    Previous character 0x0020

Classification:
    WATCOM

Systems:
     _strdec - MACRO

    _wcsdec - MACRO
    _mbsdec - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32
    _fmbsdec - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    _strinc, _strninc

See Also:

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