pshangov has asked for the wisdom of the Perl Monks concerning the following question:
my $string = "АБВ";
# $string contains first three characters of Cyrillic alphabet
print $string, "\n";
# prints strage symbols
print ord 'А', ", ", ord 'Б', ", ", ord 'В', "\n";
# prints 192, 193, 194
print chr $_ for (128, 129, 130); print "\n";
# prints "АБВ"
binmode(STDOUT, ":encoding(cp1251)");
print $string, "\n";
# prints:
# "\x{00c0}" does not map to cp1251 at test_cyr.pl line 15.
# "\x{00c1}" does not map to cp1251 at test_cyr.pl line 15.
# "\x{00c2}" does not map to cp1251 at test_cyr.pl line 15.
# \x{00c0}\x{00c1}\x{00c2}
use Encode qw(encode);
my $octets = encode("cp1251", $string);
print $octets, "\n";
# prints "???"
Any clues would be greatly appreciated.
Note: Code is in 'pre' rather than 'code' tags in order to preserve the Cyrillic characters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing cyrillic strings in cmd.exe
by almut (Canon) on Jan 23, 2007 at 11:29 UTC | |
by pshangov (Acolyte) on Jan 23, 2007 at 12:50 UTC |