Program Decoder;

Const
     BufSize  =  32768;


Var
    SF, DF : File;
NumR, NumW : Word;
         C : Word;
      R, W : Byte;
      Buf  : Array  [ 1..BufSize ] of byte;

Begin
  WriteLn;
  WriteLn('Win to ASCII decoder of French symbols');

  If ParamCount <> 2 then
                      begin
                       WriteLn('Usage: win850 FileName1 FileName2');
                       WriteLn('FileName1 - Source ( Win french text file )');
                       WriteLn('FileName2 - Destination ( ASCII text file )');
                       Halt(1);
                      end;
  If ParamStr(1) = ParamStr(2) then
                 begin
                    WriteLn ('Error! Can''t decode file to itself!');
                    Halt(2);
                 end;
  Assign  ( SF, ParamStr(1) );
  Assign  ( DF, ParamStr(2) );
  Reset   ( SF, 1 );
  ReWrite ( DF, 1 );

    Repeat
     BlockRead ( SF, Buf, SizeOf(Buf), NumR );
        For C:= 1 to BufSize do
         begin
          R :=  Buf[C];
          W := R;
          If R = 192 then W := 183;
(*        If R = 199 then W := 128; *)
(*        If R = 200 then W := 212;
	  If R = 201 then W := 144;*)
          If R = 202 then W := 138;
       (* If R = 206 then W := 215;*)
          If R = 225 then W := 182;
          If R = 240 then W := 133;
          If R = 232 then W := 144;
       (* If R = 233 then W := 130;
          If R = 234 then W := 136;
          If R = 238 then W := 140;
          If R = 244 then W := 147;
          If R = 249 then W := 151;*)
          If R = 180 then W := 39;
          If R = 199 then W := 151;
          If R = 210 then W := 147;
          If R = 216 then W := 150;
          If R = 227 then W := 128;
          If R = 242 then W := 131;
          If R = 247 then W := 135;
          If R = 248 then W := 138;
          If R = 249 then W := 130;
          If R = 250 then W := 136;
          If R = 254 then W := 140;
          If R = 219 then W := 151;
          Buf[C] := W;
        end;
     BlockWrite ( DF, Buf, NumR, NumW );
    Until ( NumR =  0 ) or ( NumR <> NumW );

  Close   ( SF );
  Close   ( DF );
End.