Well, let me take this opportunity to make a more philosophical point: in my experience, it's better to always specify a character encoding when converting from bytes to characters and back (I usually only make an exception in short scripts and/or when I know everything is ASCII). Even though it may seem a bit tedious and verbose, consider the alternative: if there is a default everywhere, then users will not get used to having to choose an encoding. Much confusion has been caused by programmers sometimes not even being aware of where en- and decoding processes are taking place. For example, AFAIK early versions of the Java standard libraries made this mistake, and many places where Strings were converted to and from arrays of bytes (especially on I/O), a default encoding was used, which as far as I can remember was just the platform default, for example Latin1 (causing issues when the files were actually encoded in e.g. CP1252 or UTF-8). If you look at it this way, then maybe you can see how specifying an encoding explicitly is like coding defensively.


In reply to Re^3: utf8 forever OR what are the best practices ...? by haukex
in thread utf8 forever OR what are the best practices ...? by pcouderc

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.