_WCRTLINK int _ismbcprint( unsigned int ch ) { #ifdef __NT__ BOOL rc; int len; char mbc[ MB_LEN_MAX + 1 ]; WORD char_type[ MB_LEN_MAX + 1 ]; _mbvtop( ch, mbc ); len = _mbclen( mbc ); mbc[ len ] = '\0'; rc = GetStringTypeEx( LOCALE_USER_DEFAULT, CT_CTYPE1, mbc, -1, char_type ); if( rc == FALSE ) return( 0 ); if( (char_type[ 0 ] & C1_CNTRL) != 0 ) return( 0 ); if( (char_type[ 0 ] & (C1_UPPER | C1_LOWER | C1_DIGIT | C1_SPACE | C1_PUNCT | C1_BLANK | C1_XDIGIT | C1_ALPHA)) == 0 ) return( 0 ); return( 1 ); #else /* OS/2 and others */ if( SINGLE_BYTE_CHAR( ch ) ) { return( isprint( ch ) ); } else { if( __MBCodePage == 932 ) { return( _ismbdprint( ch ) ); } else { return( 0 ); } } #endif }
_WCRTLINK int _ismbcpunct( unsigned int ch ) { #ifdef __NT__ BOOL rc; int len; char mbc[ MB_LEN_MAX + 1 ]; WORD char_type[ MB_LEN_MAX + 1 ]; _mbvtop( ch, mbc ); len = _mbclen( mbc ); mbc[ len ] = '\0'; rc = GetStringTypeEx( LOCALE_USER_DEFAULT, CT_CTYPE1, mbc, -1, char_type ); if( rc == FALSE ) return( 0 ); if( (char_type[ 0 ] & C1_PUNCT) == 0 ) return( 0 ); return( 1 ); #else /* OS/2 and others */ if( SINGLE_BYTE_CHAR( ch ) ) { if( __MBCodePage == 932 ) { return( ispnkana( ch ) ); } else { return( ispunct( ch ) ); } } else { return( 0 ); } #endif }
_WCRTLINK int _ismbcalpha( unsigned int ch ) { #ifdef __NT__ BOOL rc; int len; char mbc[ MB_LEN_MAX + 1 ]; WORD char_type[ MB_LEN_MAX + 1 ]; _mbvtop( ch, mbc ); len = _mbclen( mbc ); mbc[ len ] = '\0'; rc = GetStringTypeEx( LOCALE_USER_DEFAULT, CT_CTYPE1, mbc, -1, char_type ); if( rc == FALSE ) return( 0 ); if( (char_type[ 0 ] & C1_ALPHA) == 0 ) return( 0 ); return( 1 ); #else /* OS/2 and others */ if( __MBCodePage == 932 ) { /* Japanese code page */ if( SINGLE_BYTE_CHAR( ch ) ) { if( ch >= 0xA6 && ch <= 0xDF ) { /* Katakana letters */ return( 1 ); } else { return( isalpha( ch ) ); } } else { /* double-byte chars */ return( _ismbdalpha( ch ) ); } } else { if( SINGLE_BYTE_CHAR( ch ) ) { return( isalpha( ch ) ); } else { return( 0 ); } } #endif }
void main() { unsigned char string[10]; unsigned char *p; int i; _setmbcp( 932 ); p = string; _mbvtop( '.', p ); p++; _mbvtop( '1', p ); p++; _mbvtop( 'A', p ); p++; _mbvtop( 0x8140, p ); p += 2; _mbvtop( 0x8260, p ); p += 2; _mbvtop( 0x82A6, p ); p += 2; _mbvtop( '\0', p ); for( i = 0; i < 10; i++ ) printf( "%2.2x ", string[i] ); printf( "\n" ); }
_WCRTLINK int _ismbcalnum( unsigned int ch ) { #ifdef __NT__ BOOL rc; int len; char mbc[ MB_LEN_MAX + 1 ]; WORD char_type[ MB_LEN_MAX + 1 ]; _mbvtop( ch, mbc ); len = _mbclen( mbc ); mbc[ len ] = '\0'; rc = GetStringTypeEx( LOCALE_USER_DEFAULT, CT_CTYPE1, mbc, -1, char_type ); if( rc == FALSE ) return( 0 ); if( (char_type[ 0 ] & (C1_DIGIT | C1_ALPHA)) == 0 ) return( 0 ); return( 1 ); #else /* OS/2 and others */ return( _ismbcalpha( ch ) || _ismbcdigit( ch ) ); #endif }
_WCRTLINK int _ismbclegal( unsigned int ch ) { #ifdef __NT__ BOOL rc; int len; char mbc[ MB_LEN_MAX + 1 ]; WORD char_type[ MB_LEN_MAX + 1 ]; _mbvtop( ch, mbc ); len = _mbclen( mbc ); mbc[ len ] = '\0'; if( len <= 1 ) return( 0 ); rc = GetStringTypeEx( LOCALE_USER_DEFAULT, CT_CTYPE1, mbc, -1, char_type ); if( rc == FALSE ) return( 0 ); if( char_type[ 0 ] == 0 ) return( 0 ); return( 1 ); #else /* OS/2 and others */ return( _ismbblead( ch >> 8 ) && _ismbbtrail( ch & 0xFF ) ); #endif }
_WCRTLINK int _ismbccntrl( unsigned int ch ) { #ifdef __NT__ BOOL rc; int len; unsigned char mbc[ MB_LEN_MAX + 1 ]; WORD char_type[ MB_LEN_MAX + 1 ]; _mbvtop( ch, mbc ); len = _mbclen( mbc ); mbc[len] = '\0'; rc = GetStringTypeEx( LOCALE_USER_DEFAULT, CT_CTYPE1, (char *)mbc, -1, char_type ); if( rc == FALSE ) return( 0 ); if( (char_type[ 0 ] & C1_CNTRL) == 0 ) return( 0 ); return( 1 ); #else /* OS/2 and others */ if( SINGLE_BYTE_CHAR( ch ) ) { return( iscntrl( ch ) ); } else { return( 0 ); } #endif }
_WCRTLINK unsigned char _FFAR *_NEARFAR(_mbschr,_fmbschr)( const unsigned char _FFAR *string, unsigned int ch ) { char mbc[MB_LEN_MAX+1]; // if( !__IsDBCS && !ch&0xFF00 ) return( strchr( string, ch ) ); /*** Search for the specified character ***/ _mbvtop( ch, mbc ); mbc[_mbclen(mbc)] = '\0'; #ifdef __FARFUNC__ while( !_fmbterm(string) && _fmbccmp(string,mbc)!=0 ) string = _fmbsinc( string ); /* skip over character */ #else while( !_mbterm(string) && _mbccmp(string,mbc)!=0 ) string = _mbsinc( string ); /* skip over character */ #endif /*** Return character address, or NULL if not found ***/ if( !_NEARFAR(_mbterm,_fmbterm)(string) || ch==0 ) return( (unsigned char _FFAR*) string ); else return( NULL ); }
_WCRTLINK void __F_NAME(_makepath,_wmakepath)( CHAR_TYPE *path, const CHAR_TYPE *drive, const CHAR_TYPE *dir, const CHAR_TYPE *fname, const CHAR_TYPE *ext ) { UINT_WC_TYPE first_pc = NULLCHAR; #ifndef __WIDECHAR__ char *pathstart = path; unsigned ch; #endif if( drive != NULL ) { if( *drive != NULLCHAR ) { if( ( drive[0] == DIR_SEP ) && ( drive[1] == DIR_SEP ) ) { __F_NAME(strcpy, wcscpy)( path, drive ); path += __F_NAME(strlen, wcslen)( drive ); } else { *path++ = *drive; /* OK for MBCS */ *path++ = DRV_SEP; } } } *path = NULLCHAR; if( dir != NULL ) { if( *dir != NULLCHAR ) { do { #ifdef __WIDECHAR__ *path++ = pickup( *dir++, &first_pc ); #else ch = pickup( _mbsnextc( (unsigned char *)dir ), &first_pc ); _mbvtop( ch, (unsigned char *)path ); path[_mbclen( (unsigned char *)path )] = NULLCHAR; path = (char *)_mbsinc( (unsigned char *)path ); dir = (char *)_mbsinc( (unsigned char *)dir ); #endif } while( *dir != NULLCHAR ); /* if no path separator was specified then pick a default */ if( first_pc == NULLCHAR ) first_pc = DIR_SEP; /* if dir did not end in '/' then put in a provisional one */ #ifdef __WIDECHAR__ if( path[-1] == first_pc ) { path--; } else { *path = first_pc; } #else if( *(_mbsdec( (unsigned char *)pathstart, (unsigned char *)path )) == first_pc ) { path--; } else { *path = first_pc; } #endif } } /* if no path separator was specified thus far then pick a default */ if( first_pc == NULLCHAR ) first_pc = DIR_SEP; if( fname != NULL ) { #ifdef __WIDECHAR__ if( pickup( *fname, &first_pc ) != first_pc && *path == first_pc ) path++; #else ch = _mbsnextc( (unsigned char *)fname ); if( pickup( ch, &first_pc ) != first_pc && *path == first_pc ) path++; #endif while( *fname != NULLCHAR ) { //do { #ifdef __WIDECHAR__ *path++ = pickup( *fname++, &first_pc ); #else ch = pickup( _mbsnextc( (unsigned char *)fname ), &first_pc ); _mbvtop( ch, (unsigned char *)path ); path[_mbclen( (unsigned char *)path )] = NULLCHAR; path = (char *)_mbsinc( (unsigned char *)path ); fname = (char *)_mbsinc( (unsigned char *)fname ); #endif } //while( *fname != NULLCHAR ); } else { if( *path == first_pc ) { path++; } } if( ext != NULL ) { if( *ext != NULLCHAR ) { if( *ext != EXT_SEP ) *path++ = EXT_SEP; while( *ext != NULLCHAR ) { *path++ = *ext++; /* OK for MBCS */ } } } *path = NULLCHAR; }
void _RepaintWindow( LPWDATA w, PRECT rcPaint, HDC ph ) #endif { WORD i; WORD ptop, pbot, pleft, pright, poff, pdown; WORD width; #ifdef _MBCS mb_char _WCI86FAR *image; unsigned char mbc[MB_CUR_MAX + 1]; #else LPSTR image; #endif #if !defined( __OS2__ ) HFONT oldfont; #endif /* * get area to redraw */ ptop = rcPaint->top / w->ychar; if( ptop > 0 && ( rcPaint->top % w->ychar ) != 0 ) ptop--; pbot = rcPaint->bottom / w->ychar ; if( pbot == 0 ) return; if( pbot >= w->height ) pbot = w->height - 1; if( ( rcPaint->bottom % w->ychar ) == 0 ) pbot--; pleft = 0; pright = w->width - 1; width = w->width; poff = pleft * w->xchar; pdown = ptop * w->ychar; /* * draw all lines */ #if defined( __OS2__ ) #else oldfont = SelectObject( (HDC)ph, _FixedFont ); #endif for( i = ptop; i <= pbot; i++ ) { image = &w->image[i * w->width]; #if defined( __OS2__ ) { POINTL ptl; ptl.x = poff; ptl.y = ( w->y2 - w->y1 ) - ( pdown + w->ychar ) + w->base_offset; #ifdef _MBCS { WORD count; LPSTR buff; buff = FARmalloc( sizeof( mb_char ) * ( width + 1 ) ); if( buff == NULL ) _OutOfMemoryExit(); *buff = '\0'; for( count = 0; count < width; count++ ) { _mbvtop( image[pleft + count], mbc ); mbc[_mbclen( mbc )] = '\0'; FARstrcat( buff, (char *)mbc ); } GpiCharStringAt( (HPS)ph, &ptl, FAR_mbsnbcnt( (PBYTE)buff, width ), buff ); FARfree( buff ); } #else GpiCharStringAt( (HPS)ph, &ptl, width, &image[pleft] ); #endif } #else SetBkColor( (HDC)ph, _ColorMap[w->background_color] ); SetTextColor( (HDC)ph, _ColorMap[w->text_color] ); #ifdef _MBCS { WORD count; size_t bytes; LPSTR buff; buff = FARmalloc( sizeof( mb_char ) * ( width + 1 ) ); if( buff == NULL ) _OutOfMemoryExit(); *buff = '\0'; for( count = 0; count < width; count++ ) { _mbvtop( image[pleft + count], mbc ); mbc[_mbclen( mbc )] = '\0'; FARstrcat( buff, (LPSTR)mbc ); } bytes = FARstrlen( buff ); TextOut( (HDC)ph, poff, pdown, buff, bytes ); FARfree( buff ); } #else TextOut( (HDC)ph, poff, pdown, &image[pleft], width ); #endif #endif pdown += w->ychar; } #if !defined( __OS2__ ) SelectObject( (HDC)ph, oldfont ); #endif } /* _RepaintWindow */