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;
(code is untested; you can also use encode "locale", $unicode_string and binmode STDOUT, ":encoding(cp850)")use utf8; use Encode; # explicitly use for its binmodes use Encode::Locale; binmode STDOUT, ":encoding(console_out)"; my $str = "abc123äöüß"; print $str;
See also: perlunitut
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Outputting Unicode to DOS
by thekestrel (Friar) on Aug 28, 2015 at 12:05 UTC | |
by aitap (Curate) on Aug 29, 2015 at 13:49 UTC | |
by BrowserUk (Patriarch) on Aug 28, 2015 at 12:35 UTC | |
Re^2: Outputting Unicode to DOS
by thekestrel (Friar) on Aug 28, 2015 at 06:39 UTC |