Oh ye who are wise and enlightened, I am doing several regex matches using Spanish text as read from a configuration file and keep getting this message:
Malformed UTF-8 character (unexpected non-continuation byte 0x00, imme +diately after start byte 0xc3) in pattern match (m//) at /Users/spiro +s/.... line 90, <$fh> line 5.
The actual code that does the regex is :
return $n if ( $token =~ m/^$term/i );
I took some extra steps and in order to make sure all the strings I used where in UTF-8, i used Devel::Peek. Indeed all the SV's have the UTF-8 flag on:
SV = PVMG(0x1c6c2a0) at 0x1ab6a28 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0x2dd2d80 "alto"\0 [UTF8 "alto"] CUR = 4 LEN = 15 MAGIC = 0x2dd30b0 MG_VIRTUAL = &PL_vtbl_utf8 MG_TYPE = PERL_MAGIC_utf8(w) MG_LEN = 4
etc. Right before the warning, this was the output from Devel::Peek for that particular SV:
SV = PVMG(0x1c6c2a0) at 0x1ab6a28 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0x2dd2d80 "ba\303\261o"\0 [UTF8 "ba\x{f1}o"] CUR = 5 LEN = 15 MAGIC = 0x2dd30b0 MG_VIRTUAL = &PL_vtbl_utf8 MG_TYPE = PERL_MAGIC_utf8(w) MG_LEN = 4
Some reading here and there revealed that this happens when a string contains 'wide characters' as in, character sequences thus regex wont work. I am truly, madly, deeply stuck here and this is making me ANGRY and SCARED. Your help would be much appreciated.

In reply to Malformed UTF-8 by spiros

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.