MODULE EncStdMap_iso8859_9;

	(* This file was generated automatically *)

	(* Source: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-9.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..0CFH: y := x
			| 0D1H..0DCH: y := x
			| 0DFH..0EFH: y := x
			| 0F1H..0FCH: y := x
			| 0FFH: y := 0FFH
			| 011EH: y := 0D0H
			| 011FH: y := 0F0H
			| 0130H: y := 0DDH
			| 0131H: y := 0FDH
			| 015EH: y := 0DEH
			| 015FH: y := 0FEH
			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..0CFH: y := x
			| 0D0H: y := 011EH
			| 0D1H..0DCH: y := x
			| 0DDH: y := 0130H
			| 0DEH: y := 015EH
			| 0DFH..0EFH: y := x
			| 0F0H: y := 011FH
			| 0F1H..0FCH: y := x
			| 0FDH: y := 0131H
			| 0FEH: y := 015FH
			| 0FFH: y := 0FFH
			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_9.