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

In reply to Re: A definitive way to handle encoding/decoding problems? by zentara
in thread A definitive way to handle encoding/decoding problems? by DreamT

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.