in reply to Check UTF8

Beware of what you ask for. The following script removes every line that only contains valid UTF-8.

#!/usr/bin/perl use strict; use warnings; use Encode qw( decode ); while (<>) { print if !eval { decode('UTF-8', $_, Encode::FB_CROAK); 1 }; }

Usage:

A better solution might be to convert the lines to another encoding.

#!/usr/bin/perl use strict; use warnings; binmode(STDIN, ':encoding(UTF-8)'); binmode(STDOUT, ':encoding(iso-latin-1)'); print while <>;

Same usage as the original program.