#! /usr/bin/perl use strict; use warnings; use Encode; open UTF8, '>utf8.txt' or die; while (<>) { my $data = encode("utf8", $_); print UTF8 "$data\n"; } close UTF8;