From 9851146b11461d933ff5e4025d0a714f667f663c Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 6 Oct 2009 09:16:56 +0000 Subject: [PATCH] 2009-10-06 11:16 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + harbour/tests/cpinfo.prg + added simple program to generate information for Harbour CP module definition. Compile it with Clipper and link with given national sorting module (usually ntx*.obj) and then execute to generate letters strings for given national sorting module. Then use this string to define Harbour CP module in source/codepage/ directory. --- harbour/ChangeLog | 8 ++++ harbour/tests/cpinfo.prg | 96 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 harbour/tests/cpinfo.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 52961b77ef..ac3649b245 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-10-06 11:16 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + + harbour/tests/cpinfo.prg + + added simple program to generate information for Harbour CP module + definition. Compile it with Clipper and link with given national + sorting module (usually ntx*.obj) and then execute to generate + letters strings for given national sorting module. Then use this + string to define Harbour CP module in source/codepage/ directory. + 2009-10-06 03:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_misc.c + Added TODO (hb_osEncodeCP()). diff --git a/harbour/tests/cpinfo.prg b/harbour/tests/cpinfo.prg new file mode 100644 index 0000000000..3cf3f7adb7 --- /dev/null +++ b/harbour/tests/cpinfo.prg @@ -0,0 +1,96 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Simple program to generate information for Harbour CP module definition. + * Compile it with Clipper and link with given national sorting module + * (usually ntx*.obj) and then execute to generate letters strings for + * given national sorting module. Then use this string to define Harbour + * CP module in source/codepage/ directory. + * + * Copyright 2009 Przemyslaw Czerpak + * www - http://www.harbour-project.org + * + */ + + +proc main() + local cLo, cUp, c, cl, cu, i, a, lWarn + + set alternate to cpinfo.txt additive + set alternate on + + a := array( 256 ) + for i := 1 to len( a ) + a[ i ] := i - 1 + next + asort( a,,, { |x,y| chr( x ) + chr( 0 ) < chr( y ) + chr( 0 ) } ) + + ? date(), time(), os(), version() + ? "Character encoding:" + ? "===================" + lWarn := .t. + for i := 1 to len( a ) - 1 + if a[ i ] > a[ i + 1 ] + lWarn := .f. + exit + endif + next + if lWarn + ? "simple byte sorting !!!" + lWarn := .f. + endif + cLo := cUp := "" + for i := 1 to len( a ) + if i < len(a) .and. a[i] > a[ i + 1 ] .and. !isalpha( chr( a[ i ] ) ) + ? "non alpha character " + charval( chr( a[ i ] ) ) + ; + " sorted in non ASCII order !!!" + lWarn := .t. + endif + c := chr( a[ i ] ) + if isalpha( c ) + cl := lower( c ) + cu := upper( c ) + cLo += cl + cUp += cu + if cl == cu + ? "upper " + charval( cu ) + " and lower " + charval( cl ) + ; + " equal" + lWarn := .t. + elseif !isalpha( cl ) + ? "wrongly defined character " + ; + charval( c ) + ":" + charinfo( c ) + ; + ", lower " + charval( cl ) + ":" + charinfo( cl ) + lWarn := .t. + elseif !isalpha( cu ) + ? "wrongly defined character " + ; + charval( c ) + ":" + charinfo( c ) + ; + ", upper " + charval( cu ) + ":" + charinfo( cu ) + lWarn := .t. + endif + elseif islower( c ) .or. isupper( c ) + ? "wrongly defined character " + ; + charval( c ) + ":" + charinfo( c ) + lWarn := .t. + endif + next + if lWarn + ? "Warning: irregular CP which needs special definition in Harbour" + endif + ? 'upper: "' + cUp + '"' + ? 'lower: "' + cLo + '"' + ? "===================" + ? +return + +static function charval( c ) +return "'" + c + "' (" + ltrim( str( asc( c ) ) ) + ")" + +static function charinfo( c ) + local cInfo + cInfo := "ISALPHA->" + iif( isalpha( c ), "Y", "N" ) + cInfo += ", ISUPPER->" + iif( isupper( c ), "Y", "N" ) + cInfo += ", ISLOWER->" + iif( islower( c ), "Y", "N" ) +return cInfo