MODULE EncStdMap_iso8859_4;

	(* This file was generated automatically *)

	(* Source: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-4.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..0A0H,0A4H,0A7H,0A8H,0ADH,0AFH,0B0H,0B4H,0B8H,0C1H..0C6H,0C9H,0CBH,0CDH,0CEH,0D4H..0D8H,0DAH..0DCH,0DFH,0E1H..0E6H,0E9H,0EBH,0EDH,0EEH,0F4H..0F8H,0FAH..0FCH: y := 00H + x
			| 017EH: y := 0BEH
			| 014CH,0173H: y := -7AH + x
			| 0122H: y := 0ABH
			| 0129H,0145H: y := -74H + x
			| 016BH: y := 0FEH
			| 0169H: y := 0FDH
			| 0112H,0123H: y := -68H + x
			| 012EH: y := 0C7H
			| 0104H,0136H: y := -63H + x
			| 012AH,014DH: y := -5BH + x
			| 02D9H: y := 0FFH
			| 0113H: y := 0BAH
			| 0146H: y := 0F1H
			| 0105H: y := 0B1H
			| 017DH: y := 0AEH
			| 0118H: y := 0CAH
			| 0116H: y := 0CCH
			| 012FH: y := 0E7H
			| 010CH,0137H: y := -44H + x
			| 0100H,0110H: y := -40H + x
			| 012BH: y := 0EFH
			| 0166H: y := 0ACH
			| 0160H: y := 0A9H
			| 0156H: y := 0A3H
			| 0119H: y := 0EAH
			| 0117H: y := 0ECH
			| 02DBH: y := 0B2H
			| 0161H: y := 0B9H
			| 010DH: y := 0E8H
			| 0157H: y := 0B3H
			| 0101H,0111H: y := -21H + x
			| 0172H: y := 0D9H
			| 0138H: y := 0A2H
			| 013BH: y := 0A6H
			| 02C7H: y := 0B7H
			| 014AH: y := 0BDH
			| 014BH,016AH: y := -8CH + x
			| 0168H: y := 0DDH
			| 013CH: y := 0B6H
			| 0128H: y := 0A5H
			| 0167H: y := 0BCH
			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..0A0H,0A4H,0A7H,0A8H,0ADH,0AFH,0B0H,0B4H,0B8H,0C1H..0C6H,0C9H,0CBH,0CDH,0CEH,0D4H..0D8H,0DAH..0DCH,0DFH,0E1H..0E6H,0E9H,0EBH,0EDH,0EEH,0F4H..0F8H,0FAH..0FCH: y := 00H + x
			| 0C0H,0D0H: y := 40H + x
			| 0A5H: y := 0128H
			| 0B6H: y := 013CH
			| 0DDH: y := 0168H
			| 0BFH,0DEH: y := 8CH + x
			| 0BDH: y := 014AH
			| 0B7H: y := 02C7H
			| 0ECH: y := 0117H
			| 0A6H: y := 013BH
			| 0A2H: y := 0138H
			| 0D9H: y := 0172H
			| 0E0H,0F0H: y := 21H + x
			| 0B3H: y := 0157H
			| 0E8H: y := 010DH
			| 0B9H: y := 0161H
			| 0B2H: y := 02DBH
			| 0BCH: y := 0167H
			| 0EAH: y := 0119H
			| 0A3H: y := 0156H
			| 0A9H: y := 0160H
			| 0ACH: y := 0166H
			| 0EFH: y := 012BH
			| 0BEH: y := 017EH
			| 0C8H,0F3H: y := 44H + x
			| 0E7H: y := 012FH
			| 0CCH: y := 0116H
			| 0CAH: y := 0118H
			| 0AEH: y := 017DH
			| 0B1H: y := 0105H
			| 0F1H: y := 0146H
			| 0BAH: y := 0113H
			| 0FFH: y := 02D9H
			| 0CFH,0F2H: y := 5BH + x
			| 0A1H,0D3H: y := 63H + x
			| 0C7H: y := 012EH
			| 0AAH,0BBH: y := 68H + x
			| 0FDH: y := 0169H
			| 0FEH: y := 016BH
			| 0B5H,0D1H: y := 74H + x
			| 0ABH: y := 0122H
			| 0D2H,0F9H: y := 7AH + x
			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_iso8859_4.