vsespb has asked for the wisdom of the Perl Monks concerning the following question:
Note especially that the string value of $! and the error messages given by external utilities may be changed by LC_MESSAGES . If you want to have portable error codes, use %! . See Errno.Example: the following commands print different binary strings. First prints "File not found" message translated to Russian in WINDOWS-1251, second in UTF-8:
LANG=ru_RU LANGUAGE=ru_RU:ru LC_ALL=ru_RU.CP1251 LC_MESSAGES=ru_RU.CP1 +251 perl -e 'open my $f, "<", "notafile" or print $!'
I would like to convert binary strings to character strings (and print it on the screen in the end with other information):LANG=ru_RU LANGUAGE=ru_RU:ru LC_ALL=ru_RU.utf8 perl -e 'open my $f, " +<", "notafile" or print $!'
Problem is: what is the most convenient and reliable way to determine $! encoding?my $errno = decode("SOMEENCODING", $!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: locale and errno
by daxim (Curate) on Aug 27, 2013 at 15:04 UTC | |
by vsespb (Chaplain) on Aug 27, 2013 at 15:25 UTC |