Porters,
Can somebody w/ Win32 access test the patch below mentioned in RT#7831:
"piconv with ascii-incompatible output breaks on Win32" ?
http://rt.cpan.org/NoAuth/Bug.html?id=7831
I have submitted the patch but there was no response from the reporter
and I do not have an access to Win32 platforms right now.
Dan the Encode Maintainer
----
> perl -MEncode -e
> "local$/;$_=<>;binmode(STDOUT);Encode::from_to($_,'utf-8','UTF-
> 16LE');print" in > out
This should be resolved by applying binmode to the input filehandle.
The patch below
should fix that. Would you try and tell me what happens?
Dan the Maintainer Thereof
--- bin/piconv 2004/05/16 20:55:16 2.0
+++ bin/piconv 2004/09/30 18:40:17
@@ -1,5 +1,5 @@
#!./perl
-# $Id: piconv,v 2.0 2004/05/16 20:55:16 dankogai Exp dankogai $
+# $Id: piconv,v 2.0 2004/05/16 20:55:16 dankogai Exp $
#
use 5.8.0;
use strict;
@@ -52,25 +52,39 @@
EOT
}
-# default
-if ($scheme eq 'from_to'){
- while(<>){
- Encode::from_to($_, $from, $to, $Opt{check}); print;
- };
-# step-by-step
-}elsif ($scheme eq 'decode_encode'){
- while(<>){
- my $decoded = decode($from, $_, $Opt{check});
- my $encoded = encode($to, $decoded);
- print $encoded;
- };
-# NI-S favorite
-}elsif ($scheme eq 'perlio'){
- binmode(STDIN, ":encoding($from)");
- binmode(STDOUT, ":encoding($to)");
- while(<>){ print; }
-} else { # won't reach
- die "$name: unknown scheme: $scheme";
+# we do not use <> (or ARGV) for the sake of binmode()
+(_at_)ARGV or push @ARGV, \*STDIN;
+
+unless ($scheme eq 'perlio'){
+ binmode STDOUT;
+ for my $argv (@ARGV){
+ my $ifh = ref $argv ? $argv : undef;
+ $ifh or open $ifh, "<", $argv or next;
+ binmode $ifh;
+ if ($scheme eq 'from_to'){ # default
+ while(<$ifh>){
+ Encode::from_to($_, $from, $to, $Opt{check});
+ print;
+ }
+ }elsif ($scheme eq 'decode_encode'){ # step-by-step
+ while(<$ifh>){
+ my $decoded = decode($from, $_, $Opt{check});
+ my $encoded = encode($to, $decoded);
+ print $encoded;
+ }
+ } else { # won't reach
+ die "$name: unknown scheme: $scheme";
+ }
+ }
+}else{
+ # NI-S favorite
+ binmode STDOUT => "raw:encoding($to)";
+ for my $argv (@ARGV){
+ my $ifh = ref $argv ? $argv : undef;
+ $ifh or open $ifh, "<", $argv or next;
+ binmode $ifh => "raw:encoding($from)";
+ print while(<$ifh>);
+ }
}
sub list_encodings{