Johnny:
The code i summited was just a direct extract, you need to modify it for your own usage.
Append following C code to your xFWH\..\Tget.prg, for calling lBig5_1st( cString, nPos ) and lBig5_2nd( cString, nPos ) from PRG.
p.s. GB2312-1980 with simpler range : 1st byte range: A1-F7, 2nd byte range: A1-FE
Regards.
JMS
//===========================================================
#pragma BEGINDUMP
//---------------
#include "hbapi.h"
//-----------------------------
// for ChineseBig5 1st(high_order) Chr( 161 - 254 ), 2nd(Low_order) Chr( 64 - 126, 161 - 254 )
BOOL ulBig5_2nd( unsigned char * aStr, int nPos, int nLen )
{
int nn ;
unsigned int nAsc1 ;
unsigned int nAsc2 ;
if( nLen < nPos )
return FALSE ;
else if( nPos == 1 )
return FALSE ;
else if( nPos == 2 )
{
nAsc1 = aStr[0] ;
nAsc2 = aStr[1] ;
if( ( nAsc1 >= 161 && nAsc1 <= 254 ) &&
( ( nAsc2 >= 64 && nAsc2 <= 126 ) || ( nAsc2 >= 161 && nAsc2 <= 254 ) ) )
return TRUE ;
else
return FALSE ;
}
else
{
nAsc1 = aStr[nPos-2] ;
nAsc2 = aStr[nPos-1] ;
if( ( nAsc2 < 64 || ( nAsc2 > 126 && nAsc2 < 161 ) || nAsc2 > 254 ) )
return FALSE ;
else if ( nAsc1 < 161 || nAsc1 > 254 )
return FALSE ;
else
{
for( nn = 1 ; nn < nPos; nn++ )
{
nAsc1 = aStr[nn-1] ;
nAsc2 = aStr[nn] ;
if( nAsc1 >= 161 && nAsc1 <= 254 )
{
if( ( nAsc2 >= 64 && nAsc2 <= 126 ) || ( nAsc2 >= 161 && nAsc2 <= 254 ) )
{
if( nn+1 == nPos )
return TRUE ;
else if( nn < nPos-1 )
nn ++ ;
}
}
};
if( nn >= nPos )
return FALSE ;
}
}
return FALSE ;
}
//-----------------------------------------------
HB_FUNC( LBIG5_1ST ) // lBig5_1st( cString, nPos )
{
unsigned char * aStr = (unsigned char * ) hb_parc( 1 ) ;
int nPos = hb_parni( 2 ) ;
int nLen = hb_parclen( 1 ) ;
unsigned int nAsc1 ;
if( nPos < nLen )
{
nAsc1 = aStr[nPos-1] ;
if( ( nAsc1 >= 161 && nAsc1 <= 254 ) && ulBig5_2nd( aStr, nPos+1, nLen ) )
hb_retl(TRUE);
else
hb_retl(FALSE);
}
else
hb_retl(FALSE);
}
//-----------------------------------------------
HB_FUNC( LBIG5_2ND ) // lBig5_2nd( cString, nPos )
{
hb_retl( ulBig5_2nd( (unsigned char * ) hb_parc( 1 ), hb_parni( 2 ), hb_parclen( 1 ) ) ) ;
}
//----------------------------------------------------------------------------//
//-----------------------------
#pragma ENDDUMP
//===========================================================