#!perl -w use Encode; use utf8; my $test = "This is a test. Gödel"; my $cp = `chcp`; # get code page from DOS CHCP command if ($cp =~ /(\d+)/) { $cp = "cp$1"; } else { $cp = "cp437"; } binmode STDOUT, ":encoding($cp)" or die "Error on binmode: $!"; print STDOUT "$test\n";