#!/usr/bin/perl use warnings; use encoding 'utf8'; use Encode qw(from_to encode_utf8); open (INPUT, '<:encoding(utf8)', "in_file"); open( OUTPUT, '>:encoding(iso-8859-1)', "txt_file"); %utf_entity = ( "\x{2019}", '"', "\x{201c}", '"', "\x{201d}", '"', ); while () { s/(\X)(?{print ": $^N"})/ exists $utf_entity{$1} ? $utf_entity{$1} : $1/eg; $_ = encode_utf8($_); from_to ($_, "utf-8", "iso-8859-1"); print OUTPUT $_; }