2009-11-10 02:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/cdpapi.c
* harbour/include/hbapicdp.h
+ added new C functions:
hb_cdpU16AsStrLen(), hb_cdpU16ToStr(),
hb_cdpStrAsU16Len(), hb_cdpStrToU16()
* harbour/contrib/gtwvg/wvgutils.c
! fixed NULL used by mistake instead of 0
This commit is contained in:
@@ -17,6 +17,16 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-11-10 02:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/src/rtl/cdpapi.c
|
||||
* harbour/include/hbapicdp.h
|
||||
+ added new C functions:
|
||||
hb_cdpU16AsStrLen(), hb_cdpU16ToStr(),
|
||||
hb_cdpStrAsU16Len(), hb_cdpStrToU16()
|
||||
|
||||
* harbour/contrib/gtwvg/wvgutils.c
|
||||
! fixed NULL used by mistake instead of 0
|
||||
|
||||
2009-11-09 23:35 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/rddads/adsfunc.c
|
||||
* Minor cleanup.
|
||||
|
||||
@@ -1353,7 +1353,7 @@ HB_FUNC( WVT_DLGSETICON )
|
||||
hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, icon, IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
|
||||
if ( !hIcon )
|
||||
{
|
||||
hIcon = ( HICON ) LoadImage( GetModuleHandle( NULL ), icon, IMAGE_ICON, 0, 0, NULL );
|
||||
hIcon = ( HICON ) LoadImage( GetModuleHandle( NULL ), icon, IMAGE_ICON, 0, 0, 0 );
|
||||
}
|
||||
HB_TCHAR_FREE( icon );
|
||||
}
|
||||
|
||||
@@ -322,6 +322,11 @@ extern HB_EXPORT void hb_vmSetCDP( PHB_CODEPAGE pCDP );
|
||||
characters being compared are the
|
||||
same ( interleaving ) */
|
||||
|
||||
/* byte order */
|
||||
#define HB_CDP_ENDIAN_NATIVE 0
|
||||
#define HB_CDP_ENDIAN_LITTLE 1
|
||||
#define HB_CDP_ENDIAN_BIG 2
|
||||
|
||||
extern HB_EXPORT BOOL hb_cdpRegisterRaw( PHB_CODEPAGE cdp );
|
||||
extern HB_EXPORT BOOL hb_cdpRegisterNew( const char * id,
|
||||
const char * info,
|
||||
@@ -368,6 +373,11 @@ extern HB_EXPORT ULONG hb_cdpUTF8ToStr( PHB_CODEPAGE cdp, BOOL fCtrl, con
|
||||
extern HB_EXPORT ULONG hb_cdpStrAsUTF8Len( PHB_CODEPAGE cdp, BOOL fCtrl, const char * pSrc, ULONG ulSrc, ULONG ulMax );
|
||||
extern HB_EXPORT ULONG hb_cdpStrToUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, const char * pSrc, ULONG ulSrc, char * pDst, ULONG ulDst );
|
||||
|
||||
extern HB_EXPORT ULONG hb_cdpU16AsStrLen( PHB_CODEPAGE cdp, BOOL fCtrl, const HB_WCHAR * pSrc, ULONG ulSrc, ULONG ulMax );
|
||||
extern HB_EXPORT ULONG hb_cdpU16ToStr( PHB_CODEPAGE cdp, BOOL fCtrl, int iEndian, const HB_WCHAR * pSrc, ULONG ulSrc, char * pDst, ULONG ulDst );
|
||||
extern HB_EXPORT ULONG hb_cdpStrAsU16Len( PHB_CODEPAGE cdp, BOOL fCtrl, const char * pSrc, ULONG ulSrc, ULONG ulMax );
|
||||
extern HB_EXPORT ULONG hb_cdpStrToU16( PHB_CODEPAGE cdp, BOOL fCtrl, int iEndian, const char * pSrc, ULONG ulSrc, HB_WCHAR * pDst, ULONG ulDst );
|
||||
|
||||
extern HB_EXPORT PHB_ITEM hb_itemDeserializeCP( const char ** pBufferPtr, ULONG * pulSize, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut );
|
||||
extern HB_EXPORT char * hb_itemSerializeCP( PHB_ITEM pItem, BOOL fNumSize, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut, ULONG *pulSize );
|
||||
|
||||
|
||||
@@ -1107,6 +1107,234 @@ unsigned char hb_cdpGetChar( PHB_CODEPAGE cdp, BOOL fCtrl, HB_WCHAR wc )
|
||||
return wc >= 0x100 ? '?' : ( UCHAR ) wc;
|
||||
}
|
||||
|
||||
ULONG hb_cdpStrAsU16Len( PHB_CODEPAGE cdp, BOOL fCtrl,
|
||||
const char * pSrc, ULONG ulSrc,
|
||||
ULONG ulMax )
|
||||
{
|
||||
if( cdp->nMultiUC )
|
||||
{
|
||||
ULONG ulS, ulD;
|
||||
int i;
|
||||
|
||||
for( ulS = ulD = 0; ulS < ulSrc; ++ulS )
|
||||
{
|
||||
unsigned char uc = ( unsigned char ) pSrc[ ulS ];
|
||||
|
||||
if( fCtrl || uc >= 32 )
|
||||
{
|
||||
if( ( cdp->flags[ uc ] & HB_CDP_MULTI1 ) != 0 &&
|
||||
ulS + 1 < ulSrc &&
|
||||
( cdp->flags[ ( unsigned char ) pSrc[ ulS + 1 ] ] & HB_CDP_MULTI2 ) != 0 )
|
||||
{
|
||||
for( i = 0; i < cdp->nMulti; ++i )
|
||||
{
|
||||
if( pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 0 ] ||
|
||||
pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 1 ] )
|
||||
{
|
||||
if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 0 ] )
|
||||
{
|
||||
++ulS;
|
||||
break;
|
||||
}
|
||||
else if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 1 ] )
|
||||
{
|
||||
++ulS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++ulD;
|
||||
if( ulMax && ulD >= ulMax )
|
||||
break;
|
||||
}
|
||||
return ulD;
|
||||
}
|
||||
|
||||
return ulSrc;
|
||||
}
|
||||
|
||||
ULONG hb_cdpStrToU16( PHB_CODEPAGE cdp, BOOL fCtrl, int iEndian,
|
||||
const char * pSrc, ULONG ulSrc,
|
||||
HB_WCHAR * pDst, ULONG ulDst )
|
||||
{
|
||||
const HB_WCHAR * uniCodes;
|
||||
ULONG ulS, ulD;
|
||||
int i;
|
||||
|
||||
uniCodes = cdp->uniTable->uniCodes;
|
||||
for( ulS = ulD = 0; ulS < ulSrc && ulD < ulDst; ++ulS )
|
||||
{
|
||||
unsigned char uc = ( unsigned char ) pSrc[ ulS ];
|
||||
HB_WCHAR wc;
|
||||
|
||||
if( !fCtrl && uc < 32 )
|
||||
wc = uc;
|
||||
else
|
||||
{
|
||||
wc = uniCodes[ uc ];
|
||||
if( cdp->nMultiUC &&
|
||||
( cdp->flags[ uc ] & HB_CDP_MULTI1 ) != 0 &&
|
||||
ulS + 1 < ulSrc &&
|
||||
( cdp->flags[ ( unsigned char ) pSrc[ ulS + 1 ] ] & HB_CDP_MULTI2 ) != 0 )
|
||||
{
|
||||
for( i = 0; i < cdp->nMulti; ++i )
|
||||
{
|
||||
if( pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 0 ] ||
|
||||
pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 1 ] )
|
||||
{
|
||||
if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 0 ] )
|
||||
{
|
||||
wc = cdp->multi[ i ].wcUp;
|
||||
++ulS;
|
||||
break;
|
||||
}
|
||||
else if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 1 ] )
|
||||
{
|
||||
wc = cdp->multi[ i ].wcLo;
|
||||
++ulS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if !defined( HB_BIG_ENDIAN ) && !defined( HB_LITTLE_ENDIAN )
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
HB_PUT_LE_UINT16( &pDst[ ulD ], wc );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
HB_PUT_BE_UINT16( &pDst[ ulD ], wc );
|
||||
else
|
||||
pDst[ ulD ] = wc;
|
||||
++ulD;
|
||||
#else
|
||||
# if defined( HB_BIG_ENDIAN )
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
# else
|
||||
if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
# endif
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
pDst[ ulD++ ] = wc;
|
||||
#endif
|
||||
}
|
||||
if( ulD < ulDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
}
|
||||
|
||||
ULONG hb_cdpU16AsStrLen( PHB_CODEPAGE cdp, BOOL fCtrl,
|
||||
const HB_WCHAR * pSrc, ULONG ulSrc,
|
||||
ULONG ulMax )
|
||||
{
|
||||
unsigned char * uniTrans;
|
||||
HB_WCHAR wcMax, wc = 0;
|
||||
ULONG ulS, ulD;
|
||||
int i;
|
||||
|
||||
if( cdp->uniTable->uniTrans == NULL )
|
||||
hb_cdpBuildTransTable( cdp->uniTable );
|
||||
uniTrans = cdp->uniTable->uniTrans;
|
||||
wcMax = cdp->uniTable->wcMax;
|
||||
|
||||
for( ulS = ulD = 0; ulS < ulSrc; ++ulS )
|
||||
{
|
||||
wc = pSrc[ ulS ];
|
||||
++ulD;
|
||||
if( ulMax && ulD >= ulMax )
|
||||
break;
|
||||
if( wc && cdp->nMultiUC && ( fCtrl || wc >= 32 ) &&
|
||||
( wc > wcMax || uniTrans[ wc ] == 0 ) )
|
||||
{
|
||||
for( i = 0; i < cdp->nMulti; ++i )
|
||||
{
|
||||
if( wc == cdp->multi[ i ].wcUp ||
|
||||
wc == cdp->multi[ i ].wcLo )
|
||||
{
|
||||
++ulD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ulMax && ulD >= ulMax )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ulD;
|
||||
}
|
||||
|
||||
ULONG hb_cdpU16ToStr( PHB_CODEPAGE cdp, BOOL fCtrl, int iEndian,
|
||||
const HB_WCHAR * pSrc, ULONG ulSrc,
|
||||
char * pDst, ULONG ulDst )
|
||||
{
|
||||
unsigned char * uniTrans;
|
||||
HB_WCHAR wcMax, wc = 0;
|
||||
ULONG ulS, ulD;
|
||||
int i;
|
||||
|
||||
if( cdp->uniTable->uniTrans == NULL )
|
||||
hb_cdpBuildTransTable( cdp->uniTable );
|
||||
uniTrans = cdp->uniTable->uniTrans;
|
||||
wcMax = cdp->uniTable->wcMax;
|
||||
|
||||
for( ulS = ulD = 0; ulS < ulSrc && ulD < ulDst; ++ulS )
|
||||
{
|
||||
#if !defined( HB_BIG_ENDIAN ) && !defined( HB_LITTLE_ENDIAN )
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ ulS ] );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ ulS ] );
|
||||
else
|
||||
wc = pSrc[ ulS ];
|
||||
#else
|
||||
wc = pSrc[ ulS ];
|
||||
# if defined( HB_BIG_ENDIAN )
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
# else
|
||||
if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
# endif
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
#endif
|
||||
if( !fCtrl && wc < 32 )
|
||||
pDst[ ulD++ ] = ( unsigned char ) wc;
|
||||
else if( wc <= wcMax && uniTrans[ wc ] )
|
||||
pDst[ ulD++ ] = uniTrans[ wc ];
|
||||
else
|
||||
{
|
||||
if( wc && cdp->nMultiUC )
|
||||
{
|
||||
for( i = 0; i < cdp->nMulti; ++i )
|
||||
{
|
||||
if( wc == cdp->multi[ i ].wcUp )
|
||||
{
|
||||
pDst[ ulD++ ] = cdp->multi[ i ].cFirst[ 0 ];
|
||||
if( ulD < ulDst )
|
||||
pDst[ ulD++ ] = cdp->multi[ i ].cLast[ 0 ];
|
||||
break;
|
||||
}
|
||||
if( wc == cdp->multi[ i ].wcLo )
|
||||
{
|
||||
pDst[ ulD++ ] = cdp->multi[ i ].cFirst[ 1 ];
|
||||
if( ulD < ulDst )
|
||||
pDst[ ulD++ ] = cdp->multi[ i ].cLast[ 1 ];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( i < cdp->nMulti )
|
||||
continue;
|
||||
}
|
||||
pDst[ ulD++ ] = wc >= 0x100 ? '?' : ( unsigned char ) wc;
|
||||
}
|
||||
}
|
||||
|
||||
if( ulD < ulDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CP translations
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user