Created
September 29, 2010 17:08
-
-
Save ndw/603124 to your computer and use it in GitHub Desktop.
Simple Perl script to find UTF8 encoding errors in documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -- # -*- Perl -*- | |
use strict; | |
use Encode qw/encode decode/; | |
my $file = shift @ARGV || "-"; | |
my $count = 0; | |
open (F, $file); | |
while (<F>) { | |
chop; | |
$count++; | |
my $orig = $_; | |
my $utf8 = encode("utf-8", $orig); | |
if ($orig ne $utf8) { | |
print "$count: $orig\n"; | |
} | |
} | |
close (F); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment