in reply to A definitive way to handle encoding/decoding problems?

See tchrist's OSCON Perl Unicode Slides and his html slideshow ( Use arrow keys to advance/retreat the slideshow). In there is the definitive way

tchrist suggests all scripts dealing with Unicode start like this( from his slideshow): Its simple isn't it? heh heh:-)

#!/usr/bin/env perl use v5.14; use utf8; use strict; use autodie; use warnings; use warnings qw< FATAL utf8 >; use open qw< :std :encoding(UTF-8) >; use charnames qw< :full >; use feature qw< unicode_strings >; #The First of these is almost always needed; the rest, not so much. use Unicode::Normalize qw< NFD NFC >; use Encode qw< encode decode >; use Carp qw< carp croak confess cluck >; use File::Basename qw< basename >; $0 = basename($0); # shorter messages binmode(DATA, ":encoding(UTF-8)"); # This works like perl -CA: note that it # assumes your terminal is set to use UTF-8 if (grep /\P{ASCII}/ => @ARGV) { @ARGV = map { decode("UTF-8", $_) } @ARGV; } $| = 1; # comment out for performance END { close STDOUT } #This avoids compile-time “bugs” in the pragma: # XXX: use warnings FATAL => "all"; local $SIG{__DIE__} = sub { confess "Uncaught exception: @_" unless $^S; }; local $SIG{__WARN__} = sub { if ($^S) { cluck "Trapped warning: @_" } else { confess "Deadly warning: @_" } }; # I use this on normal CLI filters: if (@ARGV == 0 && -t STDIN && -t STDERR) { print STDERR "$0: reading input from tty, type ^D for EOF...\n"; } while (<>) { chomp; $_ = NFD($_); ... } continue { say NFC($_); } __END__

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh