#!/usr/bin/perl


use strict;
use File::Copy;



my $file = shift || die "please supply a file";

copy($file,"$file.messed") or die "cannot copy file: $!";

open(FH,"$file.messed") or die "cannot open file: $!";
open(OUT,">$file") or die "cannot open file: $!";

#I found the fucked up codes in this form by using vis -o



while(<FH>)
   {
	s/\342\200\231/'/g;
	s/\342\200\234/"/g;
	s/\342\200\235/"/g;
	s/\342\200\246/.../g;
	s/\s*\342\200\250\s*/\n\t/g;

	s/\311/.../g;

	s/\320/-/g;
	s/\325/'/g;
	s/\324/'/g;
	s/\322/"/g;
	s/\323/"/g;

	s/\015\n/\n/g;
	s/\015/\n/g;

	print OUT;
   }