summaryrefslogtreecommitdiff
path: root/lib/open.pm
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-03-10 15:43:54 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-10 15:43:54 +0000
commita4157ebbb54097d41b5a521795a3596543843bb8 (patch)
treef45bdd16f9f3973908f91227179c75f5afe94bd6 /lib/open.pm
parent1d88b533f61a8e86a0609fd906a86fecfadc6d1a (diff)
downloadperl-a4157ebbb54097d41b5a521795a3596543843bb8.tar.gz
The patch does the following:
- Nix the unneccessary diagnostics line - Quell -w warnings if the first ENV doesn't exist - While zh_CN means euc-cn, zh_TW almost invariably mean big5, as euc-tw is too baroque and bloated for daily use (and for perl core inclusion). - "Cannot figure out an encoding to use" when locale is 'C' is rendered non-fatal. - Consequently, the ^OPEN bits is set only when needed. p4raw-id: //depot/perl@15142
Diffstat (limited to 'lib/open.pm')
-rw-r--r--lib/open.pm14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/open.pm b/lib/open.pm
index b535d88239..e480c130de 100644
--- a/lib/open.pm
+++ b/lib/open.pm
@@ -16,10 +16,10 @@ sub _get_locale_encoding {
I18N::Langinfo->import(qw(langinfo CODESET));
$locale_encoding = langinfo(CODESET());
};
- unless ($@) {
- print "# locale_encoding = $locale_encoding\n";
- }
my $country_language;
+
+ no warnings 'uninitialized';
+
if (not $locale_encoding && in_locale()) {
if ($ENV{LC_ALL} =~ /^([^.]+)\.([^.]+)$/) {
($country_language, $locale_encoding) = ($1, $2);
@@ -45,8 +45,10 @@ sub _get_locale_encoding {
$locale_encoding = 'euc-jp';
} elsif ($country_language =~ /^ko_KR|korean?$/i) {
$locale_encoding = 'euc-kr';
+ } elsif ($country_language =~ /^zh_CN|chin(?:a|ese)?$/i) {
+ $locale_encoding = 'euc-cn';
} elsif ($country_language =~ /^zh_TW|taiwan(?:ese)?$/i) {
- $locale_encoding = 'euc-tw';
+ $locale_encoding = 'big5';
}
croak "Locale encoding 'euc' too ambiguous"
if $locale_encoding eq 'euc';
@@ -75,7 +77,7 @@ sub import {
use Encode;
_get_locale_encoding()
unless defined $locale_encoding;
- croak "Cannot figure out an encoding to use"
+ (carp("Cannot figure out an encoding to use"), last)
unless defined $locale_encoding;
if ($locale_encoding =~ /^utf-?8$/i) {
$layer = "utf8";
@@ -106,7 +108,7 @@ sub import {
croak "Unknown discipline class '$type'";
}
}
- ${^OPEN} = join("\0",$in,$out);
+ ${^OPEN} = join("\0",$in,$out) if $in or $out;
}
1;