MODULE EncStdMap_viscii;

	(* This file was generated automatically *)

	(* Source: http://www.math.nmsu.edu/~mleisher/Software/csets/VISCII.TXT *)

	IMPORT Codecs := EncCodecs;

	TYPE
		Encoder = POINTER TO RECORD (Codecs.Encoder) END;
		Decoder = POINTER TO RECORD (Codecs.Decoder) END;

	(* Encoder *)

	PROCEDURE (e: Encoder) Encode (IN f: ARRAY OF CHAR; VAR fR, fLen: INTEGER; VAR t: ARRAY OF SHORTCHAR; VAR tW: INTEGER);
		VAR x, y: INTEGER;
	BEGIN
		WHILE fLen > 0 DO
			x := ORD(f[fR]);
			CASE x OF
			| 00H,01H,03H,04H,07H..13H,15H..18H,1AH..1DH,1FH..7FH,0C0H..0C3H,0C8H..0CAH,0CCH,0CDH,0D2H..0D4H,0D9H,0DAH,0DDH,0E0H..0E3H,0E8H..0EAH,0ECH,0EDH,0F2H..0F5H,0F9H,0FAH,0FDH: y := 00H + x
			| 1EF1H: y := 0F1H
			| 1EF9H: y := 0DBH
			| 1ECBH: y := 0B8H
			| 01AFH: y := 0BFH
			| 1EBAH,1EEEH: y := -1DEFH + x
			| 0169H: y := 0FBH
			| 1EB3H,1EE5H: y := -1DEDH + x
			| 01A0H: y := 0B4H
			| 1EE7H: y := 0FCH
			| 1EDDH: y := 0B6H
			| 1ED6H: y := 92H
			| 01A1H: y := 0BDH
			| 1EF6H: y := 14H
			| 1EF8H: y := 19H
			| 1EA2H: y := 0C4H
			| 1EE3H: y := 0FEH
			| 0128H: y := 0CEH
			| 1EC7H,1EF5H: y := -1E19H + x
			| 1ECFH: y := 0F6H
			| 1ECDH: y := 0F7H
			| 1EF2H: y := 9FH
			| 01B0H: y := 0DFH
			| 1EBBH: y := 0EBH
			| 1EE2H: y := 94H
			| 1EA1H: y := 0D5H
			| 0168H: y := 9DH
			| 1EE6H: y := 9CH
			| 1EDEH: y := 97H
			| 1EDCH,1EE4H: y := -1E46H + x
			| 0111H: y := 0F0H
			| 1EABH: y := 0E7H
			| 1ED4H: y := 91H
			| 1ED2H: y := 90H
			| 1ED0H: y := 8FH
			| 0110H: y := 0D0H
			| 1EA3H: y := 0E4H
			| 0102H: y := 0C5H
			| 0129H: y := 0EEH
			| 1EC6H: y := 8EH
			| 1EC4H,1EF0H: y := -1E37H + x
			| 1EC2H: y := 8CH
			| 0D5H: y := 0A0H
			| 1EBCH,1EBEH: y := -1E34H + x
			| 1EB6H: y := 83H
			| 1ECAH,1ECCH: y := -1E32H + x
			| 1EC0H,1ECEH: y := -1E35H + x
			| 1EB2H: y := 02H
			| 1EB4H: y := 05H
			| 1EB0H,1EE8H: y := -1E2EH + x
			| 1EAEH,1EC8H,1EE0H: y := -1E2DH + x
			| 1EDFH: y := 0B7H
			| 1ED5H,1ED9H,1EF3H: y := -1E24H + x
			| 1EACH,1ED7H: y := -1E25H + x
			| 1EAAH: y := 06H
			| 1ED3H: y := 0B0H
			| 1EA8H,1ED1H: y := -1E22H + x
			| 1EA6H,1EF7H: y := -1E21H + x
			| 1EA0H,1EA4H: y := -1E20H + x
			| 1EECH: y := 0BCH
			| 0103H: y := 0E5H
			| 1ED8H,1EDAH: y := -1E45H + x
			| 1EDBH: y := 0BEH
			| 1EC9H: y := 0EFH
			| 1EB8H,1EEAH: y := -1E2FH + x
			| 1EC5H,1EE9H: y := -1E18H + x
			| 1EC3H: y := 0ACH
			| 1EC1H: y := 0ABH
			| 1EBDH,1EBFH,1EEDH: y := -1E15H + x
			| 1EB7H,1EEBH: y := -1E14H + x
			| 1EB5H: y := 0C7H
			| 1EB9H: y := 0A9H
			| 1EB1H: y := 0A2H
			| 1EAFH: y := 0A1H
			| 1EEFH: y := 0E6H
			| 1EADH: y := 0A7H
			| 1EF4H: y := 1EH
			| 1EA9H,1EE1H: y := -1E03H + x
			| 1EA7H: y := 0A5H
			| 1EA5H: y := 0A4H
			ELSE
				RETURN
			END;
			t[tW] := SHORT(CHR(y)); INC(tW);
			INC(fR); DEC(fLen)
		END
	END Encode;

	PROCEDURE NewEncoder* (): Codecs.Encoder;
		VAR e: Encoder;
	BEGIN
		NEW(e); RETURN e
	END NewEncoder;

	(* Decoder *)

	PROCEDURE (d: Decoder) Decode (IN f: ARRAY OF SHORTCHAR; VAR fR, fLen: INTEGER; VAR t: ARRAY OF CHAR; VAR tW: INTEGER; OUT state: BOOLEAN);
		VAR x, y: INTEGER;
	BEGIN
		WHILE fLen > 0 DO
			x := ORD(f[fR]);
			CASE x OF
			| 00H,01H,03H,04H,07H..13H,15H..18H,1AH..1DH,1FH..7FH,0C0H..0C3H,0C8H..0CAH,0CCH,0CDH,0D2H..0D4H,0D9H,0DAH,0DDH,0E0H..0E3H,0E8H..0EAH,0ECH,0EDH,0F2H..0F5H,0F9H,0FAH,0FDH: y := 00H + x
			| 0A4H: y := 1EA5H
			| 0A5H: y := 1EA7H
			| 0A6H,0DEH: y := 1E03H + x
			| 0F7H: y := 1ECDH
			| 0A7H: y := 1EADH
			| 0EFH: y := 1EC9H
			| 0E6H: y := 1EEFH
			| 0E5H: y := 0103H
			| 0A1H: y := 1EAFH
			| 0A2H: y := 1EB1H
			| 0A9H: y := 1EB9H
			| 0B8H: y := 1ECBH
			| 0A3H,0D7H: y := 1E14H + x
			| 0A8H,0AAH,0D8H: y := 1E15H + x
			| 0ABH: y := 1EC1H
			| 0ACH: y := 1EC3H
			| 0ADH,0D1H: y := 1E18H + x
			| 0AEH,0DCH: y := 1E19H + x
			| 89H,0BBH: y := 1E2FH + x
			| 0BEH: y := 1EDBH
			| 0DBH: y := 1EF9H
			| 0E7H: y := 1EABH
			| 80H,84H: y := 1E20H + x
			| 85H,0D6H: y := 1E21H + x
			| 86H,0AFH: y := 1E22H + x
			| 0B0H: y := 1ED3H
			| 06H: y := 1EAAH
			| 87H,0B2H: y := 1E25H + x
			| 0B6H: y := 1EDDH
			| 0B7H: y := 1EDFH
			| 0FBH: y := 0169H
			| 81H,9BH,0B3H: y := 1E2DH + x
			| 82H,0BAH: y := 1E2EH + x
			| 05H: y := 1EB4H
			| 02H: y := 1EB2H
			| 98H,9AH: y := 1E32H + x
			| 83H: y := 1EB6H
			| 88H,8AH: y := 1E34H + x
			| 8BH,99H: y := 1E35H + x
			| 8CH: y := 1EC2H
			| 8DH,0B9H: y := 1E37H + x
			| 8EH: y := 1EC6H
			| 0EEH: y := 0129H
			| 0C5H: y := 0102H
			| 0A0H: y := 0D5H
			| 0D0H: y := 0110H
			| 8FH: y := 1ED0H
			| 90H: y := 1ED2H
			| 91H: y := 1ED4H
			| 92H: y := 1ED6H
			| 93H,95H: y := 1E45H + x
			| 96H,9EH: y := 1E46H + x
			| 97H: y := 1EDEH
			| 9CH: y := 1EE6H
			| 9DH: y := 0168H
			| 0D5H: y := 1EA1H
			| 94H: y := 1EE2H
			| 0EBH: y := 1EBBH
			| 0DFH: y := 01B0H
			| 9FH: y := 1EF2H
			| 0E4H: y := 1EA3H
			| 1EH: y := 1EF4H
			| 0B1H,0B5H,0CFH: y := 1E24H + x
			| 0CEH: y := 0128H
			| 0C4H: y := 1EA2H
			| 19H: y := 1EF8H
			| 14H: y := 1EF6H
			| 0BDH: y := 01A1H
			| 0F0H: y := 0111H
			| 0FCH: y := 1EE7H
			| 0B4H: y := 01A0H
			| 0C6H,0F8H: y := 1DEDH + x
			| 0C7H: y := 1EB5H
			| 0CBH,0FFH: y := 1DEFH + x
			| 0BFH: y := 01AFH
			| 0F6H: y := 1ECFH
			| 0F1H: y := 1EF1H
			| 0BCH: y := 1EECH
			| 0FEH: y := 1EE3H
			ELSE
				RETURN
			END;
			t[tW] := CHR(y); INC(tW);
			INC(fR); DEC(fLen)
		END;
		state := FALSE
	END Decode;

	PROCEDURE (d: Decoder) Reset, EMPTY;

	PROCEDURE NewDecoder* (): Codecs.Decoder;
		VAR d: Decoder;
	BEGIN
		NEW(d); RETURN d
	END NewDecoder;

END EncStdMap_viscii.