I know it is not a regular dash, and I didn't have a regular dash in my 3 examples above, as it can be seen in the first one with Data Dumper (showing the escape sequence), and also in the second one displaying the warning about wide character.

This is the same example with first one regular dash and then an "irregular" one, using first Data Dumper to show the UTF-8 escape sequence on the irregular dash, and showing what I get with binmode:

$ perl -e ' use strict; use warnings; use utf8; use Data::Dumper; my $data = "regular dash - other type of beast: – abcd"; print Dumper $data; binmode STDOUT, ":utf8"; print "$data"; ' $VAR1 = "regular dash - other type of beast: \x{2013} abcd"; regular dash - other type of beast: – abcd
If this does not work for you and it does for me, I would suspect that either your version of Perl is too old (I am using 5.14) or that there is something wrong in your terminal configuration.

In reply to Re^3: malformed UTF-8 character in JSON string in perl by Laurent_R
in thread malformed UTF-8 character in JSON string in perl by Yllar

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.