2011-04-13 14:12 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/src/rtl/cdpapi.c
    ! fixed U+0000 conversion - it should not be converted.

  * harbour/src/rtl/hbjson.c
    ! fixed decoding unicode value from strings with \uHHHH
    ! fixed to use hb_cdpU16ToStr() instead of hb_cdpGetChar()
      which cannot be used with CPs using multibyte encoding.

  * harbour/ChangeLog
    ! fixed typos in my previos ChangeLog entry
      (I should try to read such things at least once before I'll commit)

  ; TOFIX: contrib/hbexpat/internal.c: uses hb_cdpGetU16() which cannot
           be used with CPs using multibyte encoding.
This commit is contained in:
Przemyslaw Czerpak
2011-04-13 12:13:01 +00:00
parent 30a8610407
commit 0a529d17f6
3 changed files with 49 additions and 29 deletions

View File

@@ -16,26 +16,42 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-04-13 14:12 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/cdpapi.c
! fixed U+0000 conversion - it should not be converted.
* harbour/src/rtl/hbjson.c
! fixed decoding unicode value from strings with \uHHHH
! fixed to use hb_cdpU16ToStr() instead of hb_cdpGetChar()
which cannot be used with CPs using multibyte encoding.
* harbour/ChangeLog
! fixed typos in my previos ChangeLog entry
(I should try to read such things at least once before I'll commit)
; TOFIX: contrib/hbexpat/internal.c: uses hb_cdpGetU16() which cannot
be used with CPs using multibyte encoding.
2011-04-13 11:07 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapicdp.h
* harbour/include/hbcdpreg.h
* harbour/src/rtl/cdpapi.c
* harbour/src/rtl/cdpapihb.c
+ added support for user defined character encoding.
Now it's possible to easy create and register in HVM CPs using any
encoding so I expected that users interested in adding support for
some exotic character encoding will create such mapping instead
Now it's possible to easy create and register in HVM CPs any
encoding so I expect that users interested in adding support for
new exotic character encoding will create such mapping instead
of asking for it.
% moved support for codepages using multibyte characters mapped to
single unicode values to user defined encoding - it nicely simplify
the code and eliminate unnecessary overhead in other CPs.
single unicode values to user defined encoding - it nicely simplified
the code and eliminated unnecessary overhead in other CPs.
* allow to chose UTF8 as HVM CP
* harbour/src/rtl/idle.c
! fixed idle mode flag resetting
* harbour/src/rdd/hbsix/sxutil.c
! fixed SX_SLIMFAST() results when nested quoting with (") and (') is
! fixed SX_SLIMFAST() result when nested quoting with (") and (') is
used
+ harbour/tests/big5_gen.prg
@@ -43,8 +59,8 @@
BIG5 and UCS16 using data defined by Unicode, Inc. in BIG5.TXT
+ harbour/src/codepage/cp_utf8.c
+ added alternative UTF8 Harbour CP (UTF8ASC) as an example Harbour
user defined codapged using multibyte character encoding
+ added alternative UTF8 Harbour CP (UTF8ASC) as an example of Harbour
user defined codapged with multibyte character encoding
* harbour/src/codepage/Makefile
+ harbour/src/codepage/cp_u16le.c
@@ -57,12 +73,12 @@
STR API with automatic translations.
; This CP needs really big translation tables. I added code which
makes some very simple compression which reduced raw size from
176100 bytes to 77354 but it's still large 77KB so maybe we should
176100 bytes to 77354 but it's still large (77KB) so maybe we should
think about moving this CP to other Harbour codpage library which
is not part of harbour shared library harbour*{.dll|.so|.dyn|...}
Alternatively I can try to reduce static size to about 30KB and
then build necessary tables dynamically at runtime when they are
used first time though in such case I will need additional 177KB
used first time though in such case I will need additional 176KB
of dynamic memory instead of 77KB of static memory used by current
code.

View File

@@ -162,7 +162,10 @@ void hb_cdpBuildTransTable( PHB_UNITABLE uniTable )
hb_xgrab( ( wcMax + 1 ) * sizeof( HB_UCHAR ) );
memset( uniTrans, '\0', ( wcMax + 1 ) * sizeof( HB_UCHAR ) );
for( i = 0; i < 256; ++i )
uniTrans[ uniTable->uniCodes[ i ] ] = ( HB_UCHAR ) i;
{
if( uniTable->uniCodes[ i ] )
uniTrans[ uniTable->uniCodes[ i ] ] = ( HB_UCHAR ) i;
}
uniTable->wcMax = wcMax;
uniTable->uniTrans = uniTrans;

View File

@@ -431,27 +431,28 @@ static const char * _hb_jsonDecode( const char * szSource, PHB_ITEM pValue )
break;
case 'u':
{
int i, val = 0;
HB_WCHAR wc = 0;
int i;
szSource++;
for( i = 0; i < 4 && ( ( *szSource >= '0' && *szSource <= '9' ) ||
( *szSource >= 'A' && *szSource <= 'F' ) ||
( *szSource >= 'a' && *szSource <= 'f' ) ); i++ )
for( i = 0; i < 4; i++ )
{
if( szSource[ i ] <= '9' )
val = ( val << 4 ) + szSource[ i ] - '0';
else if( *szSource <= 'F' )
val = ( val << 4 ) + szSource[ i ] - 'A' + 10;
else if( *szSource <= 'f' )
val = ( val << 4 ) + szSource[ i ] - 'a' + 10;
char c = *++szSource;
wc <<= 4;
if( c >= '0' && c <= '9' )
wc += c - '0';
else if( c >= 'A' && c <= 'F' )
wc += c - 'A' + 10;
else if( c >= 'a' && c <= 'f' )
wc += c - 'a' + 10;
else
{
hb_xfree( szDest );
return NULL;
}
}
if( i < 4 )
{
hb_xfree( szDest );
return NULL;
}
*szHead++ = hb_cdpGetChar( hb_vmCDP(), ( HB_WCHAR ) val );
szSource += 3;
szHead += hb_cdpU16ToStr( hb_vmCDP(), HB_CDP_ENDIAN_NATIVE,
&wc, 1,
szHead, szDest + nAlloc - szHead );
break;
}
default: