Sorry, I realize I wasn't specific enough:
I've read about Encode, and successfully used it in a previous project. I know about the need to decode and encode streams, too. However, it seemed to me that Perl did some of this job itself (as I had tried to explicitly decode data from the standard input, or from command-line arguments, and had experienced strange results)
So, is there some place where it is explicitly stated what is converted by perl, in a transparent manner, and what isn't ?
Furthermore, even though I didn't Encode or Decode the streams, shouldn't it "just work", if the scalar value is specified in UTF-8 (because the file is encoded as such), and Perl is AWARE that it is UTF-8 (because of 'use utf8;'), and Perl stores it internally in UTF-8, and the expected output format is UTF-8 too ?
I'm pretty sure there is a catch I haven't figured out, there, but pointing it to me, even if obvious, could help. Thanks !
EDIT: I've run a short test, using a Latin-1 terminal (this test script is fully encoded in UTF-8):
#!/usr/bin/perl
use utf8;
use Encode;
$\ = "\n";
my $unicodeScalar = "Je suis une chaîne accentuée là où il faut.";
print '['.Encode::is_utf8($unicodeScalar).'] '.$unicodeScalar;
Using my Latin-1 terminal, I displayed the source file, and, sure enough, the contents were garbled (2 strange bytes for each accentuated character, which confirmed me the file was truly UTF-8), then I ran the script. And I got a perfect display.
So, does Perl assume by default, even in a UTF-8 environment, that it should output everything in Latin-1 ? |