From: Jarkko Hietaniemi Date: Sun, 10 Mar 2002 15:43:54 +0000 (+0000) Subject: The patch does the following: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4157ebbb54097d41b5a521795a3596543843bb8;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/open.pm b/lib/open.pm index b535d88..e480c13 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;