by
Craig Petrie >> Tue, 31 Jul 2001 23:16:34 GMT
Anyone have a Jade method (or dll) to do this?
Thanks,
John Porter
The following is the implementation that Peter Fitchett and I created,: _______________________________________________________________ stringToEBCDIC(asciiValue :String) :String;
// Intent : To convert a field from PC ASCII to Unisys EBCDIC
constants
EBCDIC = #'00 01 02 03 37 2D 2E 2F 16 05 25 0B 0C 0D 0E 0F' &
#'10 11 12 13 3C 3D 32 26 18 19 3F 27 1C 1D 1E 1F' &
#'40 4F 7F 7B 5B 6C 50 7D 4D 5D 5C 4E 6B 60 4B 61' &
#'F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 7A 5E 4C 7E 6E 6F' &
#'7C C1 C2 C3 C4 C5 C6 C7 C8 C9 D1 D2 D3 D4 D5 D6' &
#'D7 D8 D9 E2 E3 E4 E5 E6 E7 E8 E9 4A E0 5A 5F 6D' &
#'79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96' &
#'97 98 99 A2 A3 A4 A5 A6 A7 A8 A9 C0 6A D0 A1 07' &
// n.b. ascii chars > 127 decimal do not have ebcdic equivalent - hence translate to null
// included in the string just in case - handles up to 255 - the complete range of 8-bit values
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' &
#'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00';
vars
i :Integer;
str :String;
begin
foreach i in 1 to asciiValue.length do
str
:= EBCDIC[asciiValue[i:1].Binary.Integer + 1]; // + 1 to get correct position in constant string(e.g. dec(1) is at pos 2)
endforeach;
epilog
return str;
end;