MODULE EncStdMap_cp1255;

	(* This file was generated automatically *)

	(* Source: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.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..0A3H,0A5H..0A9H,0ABH..0B9H,0BBH..0BFH: y := 00H + x
			| 2013H,2014H: y := -1F7DH + x
			| 05B0H..05B9H,05BBH..05C3H,05D0H..05EAH: y := -04F0H + x
			| 02DCH: y := 98H
			| 02C6H: y := 88H
			| 0F7H: y := 0BAH
			| 201CH,201DH: y := -1F89H + x
			| 2039H: y := 8BH
			| 0D7H: y := 0AAH
			| 20ACH: y := 80H
			| 2030H: y := 89H
			| 2026H: y := 85H
			| 203AH: y := 9BH
			| 05F0H..05F4H: y := -051CH + x
			| 201EH,2020H,2021H: y := -1F9AH + x
			| 201AH: y := 82H
			| 200EH,200FH: y := -1F11H + x
			| 0192H: y := 83H
			| 2022H: y := 95H
			| 2122H: y := 99H
			| 2018H,2019H: y := -1F87H + x
			| 20AAH: 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..7FH,0A0H..0A3H,0A5H..0A9H,0ABH..0B9H,0BBH..0BFH: y := 00H + x
			| 0A4H: y := 20AAH
			| 91H,92H: y := 1F87H + x
			| 93H,94H: y := 1F89H + x
			| 95H: y := 2022H
			| 83H: y := 0192H
			| 0FDH,0FEH: y := 1F11H + x
			| 82H: y := 201AH
			| 84H,86H,87H: y := 1F9AH + x
			| 0D4H..0D8H: y := 051CH + x
			| 9BH: y := 203AH
			| 85H: y := 2026H
			| 89H: y := 2030H
			| 80H: y := 20ACH
			| 0AAH: y := 0D7H
			| 8BH: y := 2039H
			| 99H: y := 2122H
			| 0BAH: y := 0F7H
			| 88H: y := 02C6H
			| 98H: y := 02DCH
			| 0C0H..0C9H,0CBH..0D3H,0E0H..0FAH: y := 04F0H + x
			| 96H,97H: y := 1F7DH + 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_cp1255.