:utf8 doesn't fix bad data.

$ perl -MDevel::Peek -we'my $buf = "\x80"; open my $fh, "<:utf8", \$bu +f or die; my $x = <$fh>; Dump $x;' utf8 "\x80" does not map to Unicode at -e line 1, <$fh> line 1. SV = PV(0x814fbb4) at 0x814f6cc REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) PV = 0x8170a78 "\200"\0Malformed UTF-8 character (unexpected continu +ation byte 0x80, with no preceding start byte) in subroutine entry at + -e line 1, <$fh> line 1. [UTF8 "\x{0}"] CUR = 1 LEN = 80

:encoding(UTF-8) replaces the bad data (with the 4 chars '\x80' in this case).

$ perl -MDevel::Peek -we'my $buf = "\x80"; open my $fh, "<:encoding(UT +F-8)", \$buf or die; my $x = <$fh>; Dump $x;' utf8 "\x80" does not map to Unicode at -e line 1. SV = PV(0x814fbb4) at 0x814f6cc REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) PV = 0x8197048 "\\x80"\0 [UTF8 "\\x80"] CUR = 4 LEN = 80

I can't answer your other questions.


In reply to Re: :utf8 I/O layer vs encoding(UTF8), segfault and speed by ikegami
in thread :utf8 I/O layer vs encoding(UTF8), segfault and speed by mje

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.