summaryrefslogtreecommitdiff
path: root/ext/Encode/encoding.pm
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-04-17 12:24:56 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-04-17 12:24:56 +0000
commitb2704119f33afe129689835c879b2897f2aaf0e4 (patch)
treeb813c2fa255f2750f21a1545503355347ec663a2 /ext/Encode/encoding.pm
parent5319f5cda006254c54e21c2a144c8f88da330a7f (diff)
downloadperl-b2704119f33afe129689835c879b2897f2aaf0e4.tar.gz
Upgrade to Encode 1.42, from Dan Kogai.
p4raw-id: //depot/perl@15965
Diffstat (limited to 'ext/Encode/encoding.pm')
-rw-r--r--ext/Encode/encoding.pm23
1 files changed, 17 insertions, 6 deletions
diff --git a/ext/Encode/encoding.pm b/ext/Encode/encoding.pm
index d5b32c7b5b..fd8ae1abac 100644
--- a/ext/Encode/encoding.pm
+++ b/ext/Encode/encoding.pm
@@ -1,5 +1,5 @@
package encoding;
-our $VERSION = do { my @r = (q$Revision: 1.26 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.28 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
use Encode;
use strict;
@@ -11,6 +11,16 @@ BEGIN {
}
}
+our $HAS_PERLIO_ENCODING;
+
+eval { require PerlIO::encoding; };
+if ($@){
+ $HAS_PERLIO_ENCODING = 0;
+}else{
+ $HAS_PERLIO_ENCODING = 1;
+ binmode(STDIN);
+}
+
sub import {
my $class = shift;
my $name = shift;
@@ -24,9 +34,10 @@ sub import {
}
unless ($arg{Filter}){
${^ENCODING} = $enc; # this is all you need, actually.
+ $HAS_PERLIO_ENCODING or return 1;
for my $h (qw(STDIN STDOUT)){
if ($arg{$h}){
- unless (defined find_encoding($arg{h})) {
+ unless (defined find_encoding($arg{$h})) {
require Carp;
Carp::croak "Unknown encoding for $h, '$arg{$h}'";
}
@@ -46,8 +57,8 @@ sub import {
eval {
require Filter::Util::Call ;
Filter::Util::Call->import ;
- binmode(STDIN, ":raw");
- binmode(STDOUT, ":raw");
+ binmode(STDIN);
+ binmode(STDOUT);
filter_add(sub{
my $status;
if (($status = filter_read()) > 0){
@@ -65,8 +76,8 @@ sub import {
sub unimport{
no warnings;
undef ${^ENCODING};
- binmode(STDIN, ":raw");
- binmode(STDOUT, ":raw");
+ binmode(STDIN);
+ binmode(STDOUT);
if ($INC{"Filter/Util/Call.pm"}){
eval { filter_del() };
}