pod2html: try to be EOL agnostic.
[p5sagit/p5-mst-13.2.git] / lib / open.pm
index 7d59d9a..a5c337a 100644 (file)
@@ -1,4 +1,5 @@
 package open;
+use warnings;
 use Carp;
 $open::hint_bits = 0x20000;
 
@@ -48,7 +49,7 @@ sub _get_locale_encoding {
            } elsif ($country_language =~ /^zh_CN|chin(?:a|ese)?$/i) {
                $locale_encoding = 'euc-cn';
            } elsif ($country_language =~ /^zh_TW|taiwan(?:ese)?$/i) {
-               $locale_encoding = 'big5';
+               $locale_encoding = 'euc-tw';
            }
            croak "Locale encoding 'euc' too ambiguous"
                if $locale_encoding eq 'euc';
@@ -81,7 +82,7 @@ sub import {
                use Encode;
                _get_locale_encoding()
                    unless defined $locale_encoding;
-               (carp("Cannot figure out an encoding to use"), last)
+               (warnings::warnif("layer", "Cannot figure out an encoding to use"), last)
                    unless defined $locale_encoding;
                if ($locale_encoding =~ /^utf-?8$/i) {
                    $layer = "utf8";
@@ -90,8 +91,11 @@ sub import {
                }
                $std = 1;
            } else {
-               unless(PerlIO::Layer::->find($layer)) {
-                   carp("Unknown discipline layer '$layer'");
+               my $target = $layer;            # the layer name itself
+               $target =~ s/^(\w+)\(.+\)$/$1/; # strip parameters
+
+               unless(PerlIO::Layer::->find($target)) {
+                   warnings::warnif("layer", "Unknown discipline layer '$layer'");
                }
            }
            push(@val,":$layer");
@@ -242,6 +246,11 @@ pragma.
 
 =back
 
+If your locale environment variables (LANGUAGE, LC_ALL, LC_CTYPE, LANG)
+contain the strings 'UTF-8' or 'UTF8' (case-insensitive matching),
+the default encoding of your STDIN, STDOUT, and STDERR, and of
+B<any subsequent file open>, is UTF-8.
+
 Directory handles may also support disciplines in future.
 
 =head1 NONPERLIO FUNCTIONALITY