MODULE EncStdMap_cp1256;

	(* This file was generated automatically *)

	(* Source: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.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,0A2H..0A9H,0ABH..0B9H,0BBH..0BEH,0D7H,0E0H,0E2H,0E7H..0EBH,0EEH,0EFH,0F4H,0F7H,0F9H,0FBH,0FCH: y := 00H + x
			| 067EH: y := 81H
			| 0686H,0688H: y := -05F9H + x
			| 0691H: y := 9AH
			| 0679H: y := 8AH
			| 2013H,2014H: y := -1F7DH + x
			| 060CH: y := 0A1H
			| 200EH,200FH: y := -1F11H + x
			| 0640H..0643H: y := -0564H + x
			| 0644H: y := 0E1H
			| 0645H..0648H: y := -0562H + x
			| 061BH: y := 0BAH
			| 061FH,0621H..0636H: y := -0560H + x
			| 0637H..063AH: y := -055FH + x
			| 0649H,064AH: y := -055DH + x
			| 064BH..064EH: y := -055BH + x
			| 064FH,0650H: y := -055AH + x
			| 0651H: y := 0F8H
			| 0652H: y := 0FAH
			| 06D2H: y := 0FFH
			| 0152H: y := 8CH
			| 02C6H: y := 88H
			| 203AH: y := 9BH
			| 0153H: y := 9CH
			| 2122H: y := 99H
			| 2039H: y := 8BH
			| 20ACH: y := 80H
			| 2030H: y := 89H
			| 2026H: y := 85H
			| 06AFH: y := 90H
			| 06BAH: y := 9FH
			| 201EH,2020H,2021H: y := -1F9AH + x
			| 200CH,200DH: y := -1F6FH + x
			| 201AH: y := 82H
			| 06BEH: y := 0AAH
			| 06A9H: y := 98H
			| 0192H: y := 83H
			| 2022H: y := 95H
			| 0698H: y := 8EH
			| 201CH,201DH: y := -1F89H + x
			| 2018H,2019H: y := -1F87H + x
			| 06C1H: y := 0C0H
			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,0A2H..0A9H,0ABH..0B9H,0BBH..0BEH,0D7H,0E0H,0E2H,0E7H..0EBH,0EEH,0EFH,0F4H,0F7H,0F9H,0FBH,0FCH: y := 00H + x
			| 0C0H: y := 06C1H
			| 91H,92H: y := 1F87H + x
			| 93H,94H: y := 1F89H + x
			| 8EH: y := 0698H
			| 95H: y := 2022H
			| 83H: y := 0192H
			| 98H: y := 06A9H
			| 0AAH: y := 06BEH
			| 82H: y := 201AH
			| 84H,86H,87H: y := 1F9AH + x
			| 9DH,9EH: y := 1F6FH + x
			| 0F5H,0F6H: y := 055AH + x
			| 90H: y := 06AFH
			| 85H: y := 2026H
			| 9FH: y := 06BAH
			| 89H: y := 2030H
			| 80H: y := 20ACH
			| 8BH: y := 2039H
			| 99H: y := 2122H
			| 9BH: y := 203AH
			| 88H: y := 02C6H
			| 8CH: y := 0152H
			| 9CH: y := 0153H
			| 0FFH: y := 06D2H
			| 0FAH: y := 0652H
			| 0F8H: y := 0651H
			| 0F0H..0F3H: y := 055BH + x
			| 81H: y := 067EH
			| 0ECH,0EDH: y := 055DH + x
			| 0D8H..0DBH: y := 055FH + x
			| 0BFH,0C1H..0D6H: y := 0560H + x
			| 0BAH: y := 061BH
			| 0E3H..0E6H: y := 0562H + x
			| 0E1H: y := 0644H
			| 0DCH..0DFH: y := 0564H + x
			| 0FDH,0FEH: y := 1F11H + x
			| 0A1H: y := 060CH
			| 8AH: y := 0679H
			| 9AH: y := 0691H
			| 8DH,8FH: y := 05F9H + 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_cp1256.