Changeset 34359
- Timestamp:
- 07/08/09 22:40:07 (4 years ago)
- Location:
- lang/perl/Encode/trunk
- Files:
-
- 1 added
- 5 modified
-
Changes (modified) (1 diff)
-
Encode.pm (modified) (1 diff)
-
MANIFEST (modified) (1 diff)
-
Makefile.PL (modified) (1 diff)
-
bin/piconv (modified) (6 diffs)
-
t/piconv.t (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Encode/trunk/Changes
r31590 r34359 1 1 # Revision history for Perl extension Encode. 2 2 # 3 # $Id: Changes,v 2.33 2009/03/25 07:55:57 dankogai Exp dankogai $ 4 $Revision: 2.33 $ $Date: 2009/03/25 07:55:57 $ 3 # $Id: Changes,v 2.34 2009/07/08 13:34:15 dankogai Exp $ 4 $Revision: 2.34 $ $Date: 2009/07/08 13:34:15 $ 5 ! bin/piconv 6 duplicate-BOM problem now fixed. 7 Message-Id: <10ECB9B7-006E-4570-9EB6-51C49F04ADCF@dan.co.jp> 8 ! bin/piconv 9 + t/piconv.t 10 patches and tests by SREZIC 11 Message-Id: <4A5366DA.8050801@iconmobile.com> 5 12 ! Makefile.PL 6 13 man* removed on behalf of blead -
lang/perl/Encode/trunk/Encode.pm
r31543 r34359 1 1 # 2 # $Id: Encode.pm,v 2.3 3 2009/03/25 07:53:19 dankogai Exp $2 # $Id: Encode.pm,v 2.34 2009/07/08 13:34:59 dankogai Exp $ 3 3 # 4 4 package Encode; 5 5 use strict; 6 6 use warnings; 7 our $VERSION = sprintf "%d.%02d", q$Revision: 2.3 3$ =~ /(\d+)/g;7 our $VERSION = sprintf "%d.%02d", q$Revision: 2.34 $ =~ /(\d+)/g; 8 8 sub DEBUG () { 0 } 9 9 use XSLoader (); -
lang/perl/Encode/trunk/MANIFEST
r7855 r34359 95 95 t/mime_header_iso2022jp.t test script 96 96 t/perlio.t test script 97 t/piconv.t test script 97 98 t/rt.pl even more test script 98 99 t/unibench.pl benchmark script -
lang/perl/Encode/trunk/Makefile.PL
r31587 r34359 1 1 # 2 # $Id: Makefile.PL,v 2. 7 2008/07/01 20:56:17dankogai Exp $2 # $Id: Makefile.PL,v 2.8 2009/07/08 13:34:15 dankogai Exp $ 3 3 # 4 4 use 5.007003; -
lang/perl/Encode/trunk/bin/piconv
r1747 r34359 1 1 #!./perl 2 # $Id: piconv,v 2. 3 2007/04/06 12:53:41dankogai Exp $2 # $Id: piconv,v 2.4 2009/07/08 13:34:15 dankogai Exp $ 3 3 # 4 4 use 5.8.0; … … 41 41 my $to = $Opt{to} || $locale or help("to_encoding unspecified"); 42 42 $Opt{string} and Encode::from_to($Opt{string}, $from, $to) and print $Opt{string} and exit; 43 my $scheme = exists $Scheme{$Opt{scheme}} ? $Opt{scheme} : 'from_to'; 43 my $scheme = do { 44 if (defined $Opt{scheme}) { 45 if (!exists $Scheme{$Opt{scheme}}) { 46 warn "Unknown scheme '$Opt{scheme}', fallback to 'from_to'.\n"; 47 'from_to'; 48 } else { 49 $Opt{scheme}; 50 } 51 } else { 52 'from_to'; 53 } 54 }; 55 44 56 $Opt{check} ||= $Opt{c}; 45 57 $Opt{perlqq} and $Opt{check} = Encode::PERLQQ; … … 57 69 } 58 70 71 my %use_bom = map { $_ => 1 } qw/UTF-16 UTF-32/; 72 59 73 # we do not use <> (or ARGV) for the sake of binmode() 60 74 @ARGV or push @ARGV, \*STDIN; … … 62 76 unless ( $scheme eq 'perlio' ) { 63 77 binmode STDOUT; 78 my $need2slurp = $use_bom{ find_encoding($to)->name }; 64 79 for my $argv (@ARGV) { 65 80 my $ifh = ref $argv ? $argv : undef; 81 $ifh or open $ifh, "<", $argv or warn "Can't open $argv: $!" and next; 66 82 $ifh or open $ifh, "<", $argv or next; 67 83 binmode $ifh; 68 84 if ( $scheme eq 'from_to' ) { # default 69 while (<$ifh>) { 70 Encode::from_to( $_, $from, $to, $Opt{check} ); 71 print; 72 } 85 if ($need2slurp){ 86 local $/; 87 $_ = <$ifh>; 88 Encode::from_to( $_, $from, $to, $Opt{check} ); 89 print; 90 }else{ 91 while (<$ifh>) { 92 Encode::from_to( $_, $from, $to, $Opt{check} ); 93 print; 94 } 95 } 73 96 } 74 97 elsif ( $scheme eq 'decode_encode' ) { # step-by-step 75 while (<$ifh>) { 98 if ($need2slurp){ 99 local $/; 100 $_ = <$ifh>; 76 101 my $decoded = decode( $from, $_, $Opt{check} ); 77 102 my $encoded = encode( $to, $decoded ); 78 103 print $encoded; 79 } 80 } 81 else { # won't reach 104 }else{ 105 while (<$ifh>) { 106 my $decoded = decode( $from, $_, $Opt{check} ); 107 my $encoded = encode( $to, $decoded ); 108 print $encoded; 109 } 110 } 111 } 112 else { # won't reach 82 113 die "$name: unknown scheme: $scheme"; 83 114 } … … 90 121 for my $argv (@ARGV) { 91 122 my $ifh = ref $argv ? $argv : undef; 123 $ifh or open $ifh, "<", $argv or warn "Can't open $argv: $!" and next; 92 124 $ifh or open $ifh, "<", $argv or next; 93 125 binmode $ifh => "raw:encoding($from)"; … … 258 290 =head1 SEE ALSO 259 291 260 L<iconv /1>261 L<locale /3>292 L<iconv(1)> 293 L<locale(3)> 262 294 L<Encode> 263 295 L<Encode::Supported>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)