#!/usr/bin/perl use utf8; use Encode; use strict; use warnings; open(FF, "<:encoding(UTF-8)",'unicode.txt'); while(){ chomp; my $l = length($_); my $str = "linenr=$. length=$l $_ \n"; if(utf8::is_utf8($str)){ # get rid of the wide character warning print encode('utf-8', $str); }else{ print $str; } } close(FF);