summaryrefslogtreecommitdiff
path: root/cpan/Encode
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2015-02-06 12:00:27 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2015-02-06 12:36:32 +0000
commit596588193775cac82eaf059a4aa065829599815a (patch)
treea9d1367baca83078bc31c642a40316ed12a4db90 /cpan/Encode
parent8d28fc8f69270cc75d9564b369ac6008c5b5d617 (diff)
downloadperl-596588193775cac82eaf059a4aa065829599815a.tar.gz
Update Encode to CPAN version 2.70
[DELTA] $Revision: 2.70 $ $Date: 2015/02/05 10:53:00 $ ! Makefile.PL add bin/encguess to EXE_FILES 2.69 2015/02/05 10:35:11 ! bin/encguess Refactored so that * does not depend on non-core module (File::Slurp in particular) * PODified document * -s "encA encB" to -s encA,encB which is more shell-friendly * and more ! MANIFEST + bin/encguess Pulled: Added CLI wrapper for Encode::Guess https://github.com/dankogai/p5-encode/pull/32 ! Unicode/Unicode.pm Pulled: Bump $VERSION in module changed since Encode-2.60 https://github.com/dankogai/p5-encode/pull/31
Diffstat (limited to 'cpan/Encode')
-rw-r--r--cpan/Encode/Encode.pm4
-rw-r--r--cpan/Encode/Encode.xs2
-rw-r--r--cpan/Encode/Makefile.PL3
-rw-r--r--cpan/Encode/Unicode/Unicode.pm2
-rw-r--r--cpan/Encode/bin/encguess145
5 files changed, 151 insertions, 5 deletions
diff --git a/cpan/Encode/Encode.pm b/cpan/Encode/Encode.pm
index c34e997d04..7a9135c671 100644
--- a/cpan/Encode/Encode.pm
+++ b/cpan/Encode/Encode.pm
@@ -1,10 +1,10 @@
#
-# $Id: Encode.pm,v 2.68 2015/01/22 10:17:32 dankogai Exp dankogai $
+# $Id: Encode.pm,v 2.70 2015/02/05 10:52:16 dankogai Exp $
#
package Encode;
use strict;
use warnings;
-our $VERSION = sprintf "%d.%02d", q$Revision: 2.68 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 2.70 $ =~ /(\d+)/g;
use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG};
use XSLoader ();
XSLoader::load( __PACKAGE__, $VERSION );
diff --git a/cpan/Encode/Encode.xs b/cpan/Encode/Encode.xs
index 7ec8d44752..73f64a8d44 100644
--- a/cpan/Encode/Encode.xs
+++ b/cpan/Encode/Encode.xs
@@ -1,5 +1,5 @@
/*
- $Id: Encode.xs,v 2.33 2015/01/22 10:17:32 dankogai Exp dankogai $
+ $Id: Encode.xs,v 2.33 2015/01/22 10:17:32 dankogai Exp $
*/
#define PERL_NO_GET_CONTEXT
diff --git a/cpan/Encode/Makefile.PL b/cpan/Encode/Makefile.PL
index 18d5915b25..8193de3f10 100644
--- a/cpan/Encode/Makefile.PL
+++ b/cpan/Encode/Makefile.PL
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.PL,v 2.12 2013/09/14 07:51:59 dankogai Exp $
+# $Id: Makefile.PL,v 2.13 2015/02/05 10:53:00 dankogai Exp dankogai $
#
use 5.007003;
use strict;
@@ -23,6 +23,7 @@ my %tables =
my @exe_files = qw(bin/enc2xs
bin/piconv
+ bin/encguess
);
my @more_exe_files = qw(
unidump
diff --git a/cpan/Encode/Unicode/Unicode.pm b/cpan/Encode/Unicode/Unicode.pm
index 75da3d7dfb..6b35cb7566 100644
--- a/cpan/Encode/Unicode/Unicode.pm
+++ b/cpan/Encode/Unicode/Unicode.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
no warnings 'redefine';
-our $VERSION = do { my @r = ( q$Revision: 2.10 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
+our $VERSION = do { my @r = ( q$Revision: 2.9 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
use XSLoader;
XSLoader::load( __PACKAGE__, $VERSION );
diff --git a/cpan/Encode/bin/encguess b/cpan/Encode/bin/encguess
new file mode 100644
index 0000000000..5d7ac80aac
--- /dev/null
+++ b/cpan/Encode/bin/encguess
@@ -0,0 +1,145 @@
+#!./perl
+use 5.008001;
+use strict;
+use warnings;
+use Encode;
+use Getopt::Std;
+use Carp;
+use Encode::Guess;
+$Getopt::Std::STANDARD_HELP_VERSION = 1;
+
+my %opt;
+getopts( "huSs:", \%opt );
+my @suspect_list;
+list_valid_suspects() and exit if $opt{S};
+@suspect_list = split /:,/, $opt{s} if $opt{s};
+HELP_MESSAGE() if $opt{h};
+HELP_MESSAGE() unless @ARGV;
+do_guess($_) for @ARGV;
+
+sub read_file {
+ my $filename = shift;
+ local $/;
+ open my $fh, '<:raw', $filename or croak "$filename:$!";
+ my $content = <$fh>;
+ close $fh;
+ return $content;
+}
+
+sub do_guess {
+ my $filename = shift;
+ my $data = read_file($filename);
+ my $enc = guess_encoding( $data, @suspect_list );
+ if ( !ref($enc) && $opt{u} ) {
+ return 1;
+ }
+ print "$filename\t";
+ if ( ref($enc) ) {
+ print $enc->mime_name();
+ }
+ else {
+ print "unknown";
+ }
+ print "\n";
+ return 1;
+}
+
+sub list_valid_suspects {
+ print join( "\n", Encode->encodings(":all") );
+ print "\n";
+ return 1;
+}
+
+sub HELP_MESSAGE {
+ exec 'pod2usage', $0 or die "pod2usage: $!"
+}
+__END__
+=head1 NAME
+
+encguess - guess character encodings of files
+
+=head1 VERSION
+
+$Id: encguess,v 0.1 2015/02/05 10:34:19 dankogai Exp $
+
+=head1 SYNOPSIS
+
+ encguess [switches] filename...
+
+=head2 SWITCHES
+
+=over 2
+
+=item -h
+
+show this message and exit.
+
+=item -s
+
+specify a list of "suspect encoding types" to test,
+seperated by either C<:> or C<,>
+
+=item -S
+
+output a list of all acceptable encoding types that can be used with
+the -s param
+
+=item -u
+
+suppress display of unidentified types
+
+=back
+
+=head2 EXAMPLES:
+
+=over 2
+
+=item *
+
+Guess encoding of a file named C<test.txt>, using only the default
+suspect types.
+
+ encguess test.txt
+
+=item *
+
+Guess the encoding type of a file named C<test.txt>, using the suspect
+types C<euc-jp,shiftjis,7bit-jis>.
+
+ encguess -s euc-jp,shiftjis,7bit-jis test.txt
+ encguess -s euc-jp:shiftjis:7bit-jis test.txt
+
+=item *
+
+Guess the encoding type of several files, do not display results for
+unidentified files.
+
+ encguess -us euc-jp,shiftjis,7bit-jis test*.txt
+
+=back
+
+=head1 DESCRIPTION
+
+The encoding identification is done by checking one encoding type at a
+time until all but the right type are eliminated. The set of encoding
+types to try is defined by the -s parameter and defaults to ascii,
+utf8 and UTF-16/32 with BOM. This can be overridden by passing one or
+more encoding types via the -s parameter. If you need to pass in
+multiple suspect encoding types, use a quoted string with the a space
+separating each value.
+
+=head1 SEE ALSO
+
+L<Encode::Guess>, L<Encode::Detect>
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright 2015 Michael LaGrasta and Dan Kogai.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the the Artistic License (2.0). You may obtain a
+copy of the full license at:
+
+L<http://www.perlfoundation.org/artistic_license_2_0>
+
+=cut