Item Subject: Message text
As promised, below is the Pascal/iX source for conversion routines.
Since all foreign language characters have a byte value of 161 or
higher, only those bytes are examined.
Originally these routines were in Visual Basic and executed on the
client side of our application, but we found that to be too slow given
VB's interpreted environment and slower 386 machines. So we moved the
logic to the server side.
The conversion tables were built using the character values in the
appendices of the Reflection for Windows Technical Reference Manual.
Good luck (and hope you have Pascal!).
$STANDARD_LEVEL 'HP_MODCAL'$
$TITLE 'FLEXCOMM - GLOBAL DECLARATIONS '$
$PAGE$
TYPE
BUFTYPE = PACKED ARRAY[1..2000] OF CHAR; {generic buffer}
BYTE = 0..255; {byte values}
CONV_A = ARRAY[161..255] OF BYTE; {for roman8/ansi convert }
VAR { convert tables for ... }
A_TO_R : CONV_A; { ansi to roman8 }
R_TO_A : CONV_A; { roman8 to ansi }
CONST
A_TO_R_C = CONV_A[ { structured constant for}
0, { ansi to roman8 table }
0,
{ 163} 187,
0,
{ 165} 188,
0,
{ 167} 189,
13 OF 0,
{ 181} 243,
10 OF 0,
{ 192} 161,
{ 193} 224,
{ 194} 162,
{ 195} 225,
{ 196} 216,
{ 197} 208,
{ 198} 211,
{ 199} 180,
{ 200} 163,
{ 201} 220,
{ 202} 164,
{ 203} 165,
{ 204} 230,
{ 205} 229,
{ 206} 166,
{ 207} 167,
{ 208} 227,
{ 209} 182,
{ 210} 232,
{ 211} 231,
{ 212} 223,
{ 213} 233,
{ 214} 218,
0,
{ 216} 210,
{ 217} 173,
{ 218} 237,
{ 219} 174,
{ 220} 219,
{ 221} 177,
{ 222} 240,
{ 223} 222,
{ 224} 200,
{ 225} 196,
{ 226} 192,
{ 227} 226,
{ 228} 204,
{ 229} 212,
{ 230} 215,
{ 231} 181,
{ 232} 201,
{ 233} 197,
{ 234} 193,
{ 235} 205,
{ 236} 217,
{ 237} 213,
{ 238} 209,
{ 239} 221,
{ 240} 228,
{ 241} 183,
{ 242} 202,
{ 243} 198,
{ 244} 194,
{ 245} 234,
{ 246} 206,
0,
{ 248} 214,
{ 249} 203,
{ 250} 199,
{ 251} 195,
{ 252} 207,
{ 253} 178,
{ 254} 241,
{ 255} 239];
CONST
R_TO_A_C = CONV_A[ { structured constant for}
{ 161} 192, { roman8 to ansi table }
{ 162} 194,
{ 163} 200,
{ 164} 202,
{ 165} 203,
{ 166} 206,
{ 167} 207,
5 OF 0,
{ 173} 217,
{ 174} 219,
0,
0,
{ 177} 221,
{ 178} 253,
0,
{ 180} 199,
{ 181} 231,
{ 182} 209,
{ 183} 241,
0,
0,
0,
{ 187} 163,
{ 188} 165,
{ 189} 167,
0,
0,
{ 192} 226,
{ 193} 234,
{ 194} 244,
{ 195} 251,
{ 196} 225,
{ 197} 233,
{ 198} 243,
{ 199} 250,
{ 200} 224,
{ 201} 232,
{ 202} 242,
{ 203} 249,
{ 204} 228,
{ 205} 235,
{ 206} 246,
{ 207} 252,
{ 208} 197,
{ 209} 238,
{ 210} 216,
{ 211} 198,
{ 212} 229,
{ 213} 237,
{ 214} 248,
{ 215} 230,
{ 216} 196,
{ 217} 236,
{ 218} 214,
{ 219} 220,
{ 220} 201,
{ 221} 239,
{ 222} 223,
{ 223} 212,
{ 224} 193,
{ 225} 195,
{ 226} 227,
{ 227} 208,
{ 228} 240,
{ 229} 205,
{ 230} 204,
{ 231} 211,
{ 232} 210,
{ 233} 213,
{ 234} 245,
0,
0,
{ 237} 218,
0,
{ 239} 255,
{ 240} 222,
{ 241} 254,
0,
{ 243} 181,
12 OF 0 ];
$TITLE ' FLEXCOMM / ANSI_TO_ROMAN8 '$
$PAGE$
PROCEDURE ansi_to_roman8(
ANYVAR S : BUFTYPE;
LENGTH : INTEGER)
OPTION UNCHECKABLE_ANYVAR;
{
This routine will convert the ANSI extended characters used by
Windows to the Roman8 extended characters used by the HP3000
system. It is called when data containing foreign language
characters needs to be sent to the HP3000.
Parameters:
S - (I/O) The buffer containing the characters to be
converted.
LENGTH - (I) The length in bytes of the buffer.
}
VAR b : BYTE;
VAR c : CHAR;
VAR i : Integer;
begin
i:= 1;
While i <= Length do
begin
c:= s[i];
IF ORD(C) > 160 THEN
BEGIN
B:= A_TO_R[ORD(C)];
IF B <> 0 THEN
S[I]:= CHR(B);
END;
i:= i + 1;
END; {while}
End; {ansi_to_roman8}
$TITLE ' FLEXCOMM / ROMAN8_TO_ANSI '$
$PAGE$
PROCEDURE roman8_to_ansi(
ANYVAR S : BUFTYPE;
LENGTH : INTEGER)
OPTION UNCHECKABLE_ANYVAR;
{
This routine will convert the Roman8 extended characters used by the
HP3000 system to the ANSI extended characters used by Windows. It is
called when data containing foreign language characters is received
from the HP3000. It will also convert any non printable chars to
blank to prevent display problems.
Parameters:
s - (I/O) The string containing the characters to be
converted.
LENGTH - (I) The length in bytes of the buffer.
}
VAR b : BYTE;
VAR c : CHAR;
VAR i : Integer;
BEGIN
i:= 1;
While i <= Length DO
begin
c:= s[i];
IF ORD(C) > 160 THEN
BEGIN
B:= R_TO_A[ORD(C)];
IF B <> 0 THEN
S[I]:= CHR(B);
END
ELSE IF ORD(C) IN [0..8,10..31] THEN
S[I]:= ' '; {replace all nonprintable characters other}
{than the tab char with a blank}
i:= i + 1;
END; {while}
End; {procedure roman8_to_ansi}
|