This is a bit tricky and a known shortcoming of Perl which isn't all that easy to fix.
To start with, Perl does not know which encoding the file system applies to represent polish characters, and you have no way of specifying it. So, the name of your source file is known to Perl as bytes, encoded in whatever encoding the file system chooses. Nowadays, unless you are on Windows, UTF-8 is a reasonable guess, but Perl does not guess.
Your command line parameter -CS then enforces UTF-8 encoding of STDERR, which is fine for the characters in your error message but not for file names. So, you get the file name doubly encoded.
One way to get out of this is to apply encoding yourself, and drop the command line parameters. This sort of works, but makes the assumption that the file name is encoded in UTF-8:
#!/usr/bin/perl
# saved as ąćęłńó.pl
use utf8;
use Encode qw(encode);
die encode('UTF-8',"language specific chars: ąćęłńó");
Edited because I forgot (again) that the code tags break non-ASCII characters
|