Skip to content

Instantly share code, notes, and snippets.

@ndw
Created September 29, 2010 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndw/603124 to your computer and use it in GitHub Desktop.
Save ndw/603124 to your computer and use it in GitHub Desktop.
Simple Perl script to find UTF8 encoding errors in documents
#!/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