Is -C useless?
Dagfinn Ilmari Mannsåker
ilmari at ilmari.org
Fri Sep 12 00:34:15 BST 2008
Paul LeoNerd Evans <leonerd at leonerd.org.uk> writes:
> On Thu, 11 Sep 2008 15:19:17 +0200
> Paul Johnson <paul at pjcj.net> wrote:
>
>> Which is just what you seem to have discovered ;-)
>
> In that case, I might have to consider the following:
>
> package utf8::LocaleAware;
>
> my $converted = 0;
>
> sub import
> {
> return if $converted;
> $converted = 1;
>
> return unless $ENV{LANG} =~ m/\.UTF-8/;
You want LC_CTYPE, which can be inherited from LANG or overridden by
LC_ALL. Also, not all the world is UTF-8.
you want something like this:
require I18N::Langinfo;
require Encode;
my encoding = I18N::Langinfo::langinfo(I18N::Langinfo::CODESET());
binmode STDIN, ":encoding($encoding)";
binmode STDOUT, ":encoding($encoding)";
binmode STDERR, ":encoding($encoding)";
map { $_ = Encode::decode($encoding, $_) } @ARGV, values %ENV;
> binmode STDIN, ":utf8";
> binmode STDOUT, ":utf8";
>
> require Encode;
> map { $_ = Encode::decode_utf8 $_ } @ARGV, values %ENV;
> }
--
ilmari
"A disappointingly low fraction of the human race is,
at any given time, on fire." - Stig Sandbeck Mathisen
More information about the london.pm
mailing list