sub _get_locale_encoding {
unless (defined $locale_encoding) {
- eval { require I18N::Langinfo;
- import I18N::Langinfo qw(langinfo CODESET) };
+ eval {
+ # I18N::Langinfo isn't available everywhere
+ require I18N::Langinfo;
+ I18N::Langinfo->import('langinfo', 'CODESET');
+ };
unless ($@) {
- $locale_encoding = langinfo(CODESET);
+ $locale_encoding = langinfo(CODESET());
}
my $country_language;
if (not $locale_encoding && in_locale()) {
defined $country_language) {
if ($country_language =~ /^ja_JP|japan(?:ese)?$/i) {
$locale_encoding = 'eucjp';
- } elsif ($country_language =~ /^ko_KR|korea(?:n)?$/i) {
+ } elsif ($country_language =~ /^ko_KR|korean?$/i) {
$locale_encoding = 'euckr';
} elsif ($country_language =~ /^zh_TW|taiwan(?:ese)?$/i) {
$locale_encoding = 'euctw';
my ($class,@args) = @_;
croak("`use open' needs explicit list of disciplines") unless @args;
$^H |= $open::hint_bits;
- my ($in,$out) = split(/\0/,(${^OPEN} || '\0'));
- my @in = split(/\s+/,$in);
- my @out = split(/\s+/,$out);
+ my ($in,$out) = split(/\0/,(${^OPEN} || "\0"), -1);
while (@args) {
my $type = shift(@args);
my $discp = shift(@args);
if ($locale_encoding =~ /^utf-?8$/i) {
$layer = "utf8";
} else {
- $layer = "encoding($locale_encoding)";
+ $layer = "encoding";
}
}
unless(PerlIO::Layer::->find($layer)) {
carp("Unknown discipline layer '$layer'");
}
+ if (defined $locale_encoding) {
+ $layer = "$layer($locale_encoding)";
+ }
push(@val,":$layer");
if ($layer =~ /^(crlf|raw)$/) {
$^H{"open_$type"} = $layer;