http://qs321.pair.com?node_id=1140226


in reply to Outputting Unicode to DOS

Please don't use encoding: it's deprecated.

Instead, either don't recode anything (and store the file in the same character encoding as your terminal uses, likely cp850, check the output of chcp command), or do store your program in UTF-8 and use utf8 (thus your text is stored as characters and you are able to perform unicode-related string operations) and encode the strings you print back to bytes (the characters have to be stored in some encoding, thus if you do not encode them, Perl warns and outputs latin1 or UTF-8), possibly with the help of Encode::Locale:

use utf8; use Encode 'encode'; my $str = "abc123äöüß"; print encode cp850 => $str;
use utf8; use Encode; # explicitly use for its binmodes use Encode::Locale; binmode STDOUT, ":encoding(console_out)"; my $str = "abc123äöüß"; print $str;
(code is untested; you can also use encode "locale", $unicode_string and binmode STDOUT, ":encoding(cp850)")

See also: perlunitut