MODULE EncStdMap_ptcp154;

	(* This file was generated automatically *)

	(* Source: http://www.math.nmsu.edu/~mleisher/Software/csets/PTCP154.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..7FH,0A0H,0A7H,0A9H,0ABH,0ACH,0AEH,0B0H,0B6H,0B7H,0BBH: y := 00H + x
			| 04B1H: y := 0B1H
			| 049BH: y := 9DH
			| 2013H,2014H: y := -1F7DH + x
			| 2022H: y := 95H
			| 0498H: y := 0A5H
			| 040EH: y := 0A1H
			| 04EEH: y := 82H
			| 0499H: y := 0B4H
			| 049DH: y := 0BFH
			| 0408H: y := 0A3H
			| 0401H: y := 0A8H
			| 04E2H: y := 8BH
			| 0406H: y := 0B2H
			| 0410H..044FH: y := -0350H + x
			| 049AH: y := 8DH
			| 2018H,2019H: y := -1F87H + x
			| 04E3H: y := 9BH
			| 04E8H: y := 0A4H
			| 04EFH: y := 0ADH
			| 045EH: y := 0A2H
			| 04E9H: y := 0B5H
			| 04B6H: y := 86H
			| 04D8H: y := 0AAH
			| 2116H: y := 0B9H
			| 04BAH: y := 8EH
			| 04B2H: y := 88H
			| 04B8H: y := 8FH
			| 04AEH: y := 87H
			| 04AFH: y := 89H
			| 0456H: y := 0B3H
			| 2026H: y := 85H
			| 04D9H: y := 0BAH
			| 04B7H: y := 99H
			| 04BBH: y := 9EH
			| 0458H: y := 0BCH
			| 04B3H: y := 98H
			| 04B9H: y := 9FH
			| 0451H: y := 0B8H
			| 0496H,04A0H,04A2H: y := -0416H + x
			| 0492H: y := 81H
			| 0493H: y := 83H
			| 049CH,04AAH,04ABH: y := -03EDH + x
			| 04B0H: y := 0A6H
			| 201CH,201DH: y := -1F89H + x
			| 0497H,04A1H,04A3H: y := -0407H + x
			| 201EH: y := 84H
			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..7FH,0A0H,0A7H,0A9H,0ABH,0ACH,0AEH,0B0H,0B6H,0B7H,0BBH: y := 00H + x
			| 0B1H: y := 04B1H
			| 91H,92H: y := 1F87H + x
			| 93H,94H: y := 1F89H + x
			| 0A6H: y := 04B0H
			| 8DH: y := 049AH
			| 0AFH,0BDH,0BEH: y := 03EDH + x
			| 83H: y := 0493H
			| 81H: y := 0492H
			| 80H,8AH,8CH: y := 0416H + x
			| 0B8H: y := 0451H
			| 84H: y := 201EH
			| 98H: y := 04B3H
			| 0BCH: y := 0458H
			| 9EH: y := 04BBH
			| 99H: y := 04B7H
			| 0BAH: y := 04D9H
			| 85H: y := 2026H
			| 0B3H: y := 0456H
			| 89H: y := 04AFH
			| 87H: y := 04AEH
			| 8FH: y := 04B8H
			| 88H: y := 04B2H
			| 90H,9AH,9CH: y := 0407H + x
			| 8EH: y := 04BAH
			| 0AAH: y := 04D8H
			| 86H: y := 04B6H
			| 9FH: y := 04B9H
			| 0B5H: y := 04E9H
			| 0A2H: y := 045EH
			| 0ADH: y := 04EFH
			| 0A4H: y := 04E8H
			| 9BH: y := 04E3H
			| 95H: y := 2022H
			| 0C0H..0FFH: y := 0350H + x
			| 0B2H: y := 0406H
			| 8BH: y := 04E2H
			| 0A8H: y := 0401H
			| 0B9H: y := 2116H
			| 0BFH: y := 049DH
			| 0B4H: y := 0499H
			| 0A3H: y := 0408H
			| 82H: y := 04EEH
			| 0A1H: y := 040EH
			| 0A5H: y := 0498H
			| 96H,97H: y := 1F7DH + x
			| 9DH: y := 049BH
			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_ptcp154.