From 1585573c61862430e85e53d775362b2a74f37acc Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 10 Nov 2009 10:00:28 +0000 Subject: [PATCH] 2009-11-10 11:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/tests/cpinfo.prg + try to generate HB_CP_UPPER and HB_CP_LOWER strings which are ready to use in Harbour CP definition using human readable form. Warning: please remember that not all CPs can be created in human readable form and if you want to create Clipper compatible definition then it should be always verified by comparing .c files generated by cpinfo compiled using Clipper and Harbour. --- harbour/ChangeLog | 9 +++++++++ harbour/tests/cpinfo.prg | 42 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index db45497ed2..e69009df7c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,15 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-11-10 11:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/tests/cpinfo.prg + + try to generate HB_CP_UPPER and HB_CP_LOWER strings which are ready to + use in Harbour CP definition using human readable form. + Warning: please remember that not all CPs can be created in human + readable form and if you want to create Clipper compatible + definition then it should be always verified by comparing .c + files generated by cpinfo compiled using Clipper and Harbour. + 2009-11-10 09:43 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/codepage/cphu852c.c * converted to use human readable form which I think should better diff --git a/harbour/tests/cpinfo.prg b/harbour/tests/cpinfo.prg index 917eadd7b3..aaff521004 100644 --- a/harbour/tests/cpinfo.prg +++ b/harbour/tests/cpinfo.prg @@ -165,12 +165,50 @@ proc main( cdp, info, unicode ) if lWarn ? "Warning: irregular CP which needs special definition in Harbour" endif - ? 'upper: "' + cUp + '"' - ? 'lower: "' + cLo + '"' + ? ' upper: "' + cUp + '"' + ? ' lower: "' + cLo + '"' + if pad_letters( @cUp, @cLo ) + ? 'HB_CP_UPPER: "' + cUp + '"' + ? 'HB_CP_LOWER: "' + cLo + '"' + endif ? repl( "=", 50 ) ? return +static function pad_letters( cUp, cLo ) + local lRet, cUp2, cLo2, cU, cL, i, j + + cUp2 := cLo2 := "" + + i := j := 1 + while i <= len( cUp ) .or. j <= len( cLo ) + cU := substr( cUp, i, 1 ) + cL := substr( cLo, j, 1 ) + if upper( cL ) == cU .and. lower( cU ) == cL + ++i + ++j + elseif cL == "" .or. !islower( lower( cU ) ) + cL := " " + ++i + elseif cU == "" .or. !isupper( upper( cL ) ) + cU := " " + ++j + elseif upper( cL ) $ substr( cUp, i + 1 ) + cL := lower( cU ) + ++i + else + cU := upper( cL ) + ++j + endif + cUp2 += cU + cLo2 += cL + enddo + + lRet := !( cUp == cUp2 .and. cLo == cLo2 ) + cUp := cUp2 + cLo := cLo2 +return lRet + static function charval( c ) return "'" + c + "' (" + ltrim( str( asc( c ) ) ) + ")"