From 9fa9f003afe638ec3cc2a88a88fb366b5c59b6b5 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Sat, 9 Apr 2011 23:27:04 +0000 Subject: [PATCH] 2011-04-10 01:26 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/cdpapi.c ! some fixes for future CPs which may have together multibyte characters with and without single UNICODE representation. --- harbour/ChangeLog | 5 ++ harbour/src/rtl/cdpapi.c | 120 +++++++++++++++++++++++++-------------- 2 files changed, 83 insertions(+), 42 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9921eb786c..525cbcb0b1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2011-04-10 01:26 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/rtl/cdpapi.c + ! some fixes for future CPs which may have together multibyte + characters with and without single UNICODE representation. + 2011-04-09 11:08 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtgui/hbqt_hbqabstractitemmodel.cpp ! Fixed: to supply strings per UTF8 conversion to Qt. diff --git a/harbour/src/rtl/cdpapi.c b/harbour/src/rtl/cdpapi.c index bd55faca21..64780a6b77 100644 --- a/harbour/src/rtl/cdpapi.c +++ b/harbour/src/rtl/cdpapi.c @@ -916,25 +916,34 @@ HB_SIZE hb_cdpStrAsUTF8Len( PHB_CODEPAGE cdp, HB_BOOL fCtrl, wc = uniCodes[ uc ]; if( cdp->nMultiUC && ( cdp->flags[ uc ] & HB_CDP_MULTI1 ) != 0 && - ulS + 1 < nSrc && - ( cdp->flags[ ( HB_UCHAR ) pSrc[ ulS + 1 ] ] & HB_CDP_MULTI2 ) != 0 ) + ulS + 1 < nSrc ) { - for( i = 0; i < cdp->nMulti; ++i ) + HB_UCHAR uc2 = ( HB_UCHAR ) pSrc[ ulS + 1 ]; + if( ( cdp->flags[ uc2 ] & HB_CDP_MULTI2 ) != 0 ) { - if( pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 0 ] || - pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 1 ] ) + for( i = 0; i < cdp->nMulti; ++i ) { - if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 0 ] ) + if( uc2 == cdp->multi[ i ].cLast[ 0 ] || + uc2 == cdp->multi[ i ].cLast[ 1 ] ) { - wc = cdp->multi[ i ].wcUp; - ++ulS; - break; - } - else if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 1 ] ) - { - wc = cdp->multi[ i ].wcLo; - ++ulS; - break; + if( uc == cdp->multi[ i ].cFirst[ 0 ] ) + { + if( cdp->multi[ i ].wcUp ) + { + wc = cdp->multi[ i ].wcUp; + ++ulS; + } + break; + } + else if( uc == cdp->multi[ i ].cFirst[ 1 ] ) + { + if( cdp->multi[ i ].wcLo ) + { + wc = cdp->multi[ i ].wcLo; + ++ulS; + } + break; + } } } } @@ -980,25 +989,34 @@ HB_SIZE hb_cdpStrToUTF8( PHB_CODEPAGE cdp, HB_BOOL fCtrl, wc = uniCodes[ uc ]; if( cdp->nMultiUC && ( cdp->flags[ uc ] & HB_CDP_MULTI1 ) != 0 && - ulS + 1 < nSrc && - ( cdp->flags[ ( HB_UCHAR ) pSrc[ ulS + 1 ] ] & HB_CDP_MULTI2 ) != 0 ) + ulS + 1 < nSrc ) { - for( i = 0; i < cdp->nMulti; ++i ) + HB_UCHAR uc2 = ( HB_UCHAR ) pSrc[ ulS + 1 ]; + if( ( cdp->flags[ uc2 ] & HB_CDP_MULTI2 ) != 0 ) { - if( pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 0 ] || - pSrc[ ulS + 1 ] == cdp->multi[ i ].cLast[ 1 ] ) + for( i = 0; i < cdp->nMulti; ++i ) { - if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 0 ] ) + if( uc2 == cdp->multi[ i ].cLast[ 0 ] || + uc2 == cdp->multi[ i ].cLast[ 1 ] ) { - wc = cdp->multi[ i ].wcUp; - ++ulS; - break; - } - else if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 1 ] ) - { - wc = cdp->multi[ i ].wcLo; - ++ulS; - break; + if( uc == cdp->multi[ i ].cFirst[ 0 ] ) + { + if( cdp->multi[ i ].wcUp ) + { + wc = cdp->multi[ i ].wcUp; + ++ulS; + } + break; + } + else if( uc == cdp->multi[ i ].cFirst[ 1 ] ) + { + if( cdp->multi[ i ].wcLo ) + { + wc = cdp->multi[ i ].wcLo; + ++ulS; + } + break; + } } } } @@ -1285,14 +1303,20 @@ HB_SIZE hb_cdpStrToU16( PHB_CODEPAGE cdp, HB_BOOL fCtrl, int iEndian, { if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 0 ] ) { - wc = cdp->multi[ i ].wcUp; - ++ulS; + if( cdp->multi[ i ].wcUp ) + { + wc = cdp->multi[ i ].wcUp; + ++ulS; + } break; } else if( pSrc[ ulS ] == cdp->multi[ i ].cFirst[ 1 ] ) { - wc = cdp->multi[ i ].wcLo; - ++ulS; + if( cdp->multi[ i ].wcLo ) + { + wc = cdp->multi[ i ].wcLo; + ++ulS; + } break; } } @@ -1515,14 +1539,20 @@ HB_SIZE hb_cdpTransLen( const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax, { if( pSrc[ ul ] == cdpIn->multi[ i ].cFirst[ 0 ] ) { - wc = cdpIn->multi[ i ].wcUp; - ++ul; + if( cdpIn->multi[ i ].wcUp ) + { + wc = cdpIn->multi[ i ].wcUp; + ++ul; + } break; } else if( pSrc[ ul ] == cdpIn->multi[ i ].cFirst[ 1 ] ) { - wc = cdpIn->multi[ i ].wcLo; - ++ul; + if( cdpIn->multi[ i ].wcLo ) + { + wc = cdpIn->multi[ i ].wcLo; + ++ul; + } break; } } @@ -1598,14 +1628,20 @@ HB_SIZE hb_cdpTransTo( const char * pSrc, HB_SIZE nSrc, { if( pSrc[ ul ] == cdpIn->multi[ i ].cFirst[ 0 ] ) { - wc = cdpIn->multi[ i ].wcUp; - ++ul; + if( cdpIn->multi[ i ].wcUp ) + { + wc = cdpIn->multi[ i ].wcUp; + ++ul; + } break; } else if( pSrc[ ul ] == cdpIn->multi[ i ].cFirst[ 1 ] ) { - wc = cdpIn->multi[ i ].wcLo; - ++ul; + if( cdpIn->multi[ i ].wcLo ) + { + wc = cdpIn->multi[ i ].wcLo; + ++ul; + } break; } }