I am encountering a strange problem in printing Unicode strings to the Windows console*.
Consider this text:
אני רוצה לישון
Intermediary
היא רוצה לישון
אתם, הם
Bye
Hello, world!
test
Assume it's in a file called "file.txt".
When I go*: "type file.txt", it prints out fine. But when it's printed from a Perl program, like this:
 use strict;
 use warnings;
 use Encode;
 use 5.014;
 use utf8;
 use autodie;
 use warnings    qw< FATAL  utf8     >;
 use open        qw< :std  :utf8     >;
 use feature     qw< unicode_strings >;
 use warnings 'all';
 binmode STDOUT, ':utf8';   # output should be in UTF-8
 my $word;
 my @array = ( 'אני רוצה לישון', 'Intermediary',
    'היא רוצה לישון', 'אתם, הם', 'Bye','Hello, world!', 'test');
 foreach $word(@array) {
    say $word;
 }
The Unicode lines (Hebrew in this case) show up again each time, partially broken, like this:
E:\My Documents\Technical\Perl>perl "hello unicode.pl"
אני רוצה לישון
לישון
�ן
Intermediary
היא רוצה לישון
לישון
�ן
אתם, הם
�ם
Bye
Hello, world!
test
(I save everything in UTF-8).
This is mighty strange. Any suggestions?
(It's not a "Console2" problem* - the same problem shows up on a "regular" windows console, only there you don't see the Hebrew glyphs).
* Using "Console" (also called "Console2") - it's a nice little utility which enables working with Unicode with the Windows console - see, for example, here: http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx
** Note: at the console, you have to say, of course:
chcp 65001
 
     
     
     
     
    
`, `
` tags all over the place.– sarnold Feb 21 '12 at 01:08