Octavian Rasnita <[EMAIL PROTECTED]> writes: >I have tried the following script: > >#!/perl/bin/perl -wC > >use Encode; > >my $text = Encode::decode('latin2', 'mÃta'); > >binmode(STDOUT, ":utf8"); > >print "Content-Type: text/html; Charset=UTF-8\n\n"; >print Encode::encode('utf8', $text); >
You have double-encoded that. $text is correctly decoded from Latin2. So $text is Unicode. Then you encode it is utf8 manually with Encode::encode() AND THEN AGAIN as you have told perl with binmode() that STDOUT is to be encoded as utf8. Either loose the binmode(): #!/perl/bin/perl -wC use Encode; print "Content-Type: text/html; Charset=UTF-8\n\n"; print Encode::encode('utf8', $text); __END__ or the explict encode: #!/perl/bin/perl -wC use Encode; my $text = Encode::decode('latin2', 'mÃta'); binmode(STDOUT, ":utf8"); print "Content-Type: text/html; Charset=UTF-8\n\n"; print $text; __END__