unit ebcdic;
interface
function EBCDICtoASCII(
const c: Byte): Byte;
procedure SetInvalid(
const c: Byte);
implementation
const
InvalidTableEntry: Byte = $1A;
Table:
array[0..255]
of Byte = ($00,$01,$02,$03,$1A,$09,$1A,$7F,$1A,$1A,$1A,$0B,$0C,$0D,$0E,$0F,
$10,$11,$12,$13,$1A,$1A,$08,$1A,$18,$19,$1A,$1A,$1C,$1D,$1E,$1F,
$1A,$1A,$1A,$1A,$1A,$0A,$17,$1B,$1A,$1A,$1A,$1A,$1A,$05,$06,$07,
$1A,$1A,$16,$1A,$1A,$1A,$1A,$04,$1A,$1A,$1A,$1A,$14,$15,$1A,$1A,
$20,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$5B,$2E,$3C,$28,$2B,$21,
$26,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$5D,$24,$2A,$29,$3B,$5E,
$2D,$2F,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$7C,$2C,$25,$5F,$3E,$3F,
$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$60,$3A,$23,$40,$27,$3D,$22,
$1A,$61,$62,$63,$64,$65,$66,$67,$68,$69,$1A,$1A,$1A,$1A,$1A,$1A,
$1A,$6A,$6B,$6C,$6D,$6E,$6F,$70,$71,$72,$1A,$1A,$1A,$1A,$1A,$1A,
$1A,$7E,$73,$74,$75,$76,$77,$78,$79,$7A,$1A,$1A,$1A,$1A,$1A,$1A,
$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,$1A,
$7B,$41,$42,$43,$44,$45,$46,$47,$48,$49,$1A,$1A,$1A,$1A,$1A,$1A,
$7D,$4A,$4B,$4C,$4D,$4E,$4F,$50,$51,$52,$1A,$1A,$1A,$1A,$1A,$1A,
$5C,$1A,$53,$54,$55,$56,$57,$58,$59,$5A,$1A,$1A,$1A,$1A,$1A,$1A,
$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$1A,$1A,$1A,$1A,$1A,$1A);
var
Invalid: BYTE;
function EBCDICtoASCII(
const c: Byte): Byte;
begin
Result := Table[c];
if Result = InvalidTableEntry
Then
Result := Invalid;
end;
procedure SetInvalid(
const c: Byte);
begin
Invalid := c;
end;
initialization
SetInvalid($20);
end.