Well, maybe the status of the utf8 flag on the regex could be irrelevant, but if the regex has characters in one encoding, and the string you apply it to is in some other encoding, there's no way it can work as intended.

I don't get it. I thought I said I normalize both to UTF8..? Okay, so I probably wasn't clear. If the following doesn't make clear why I'm confused, then I will just have to admit that I don't know what I'm doing at all...

# assume all encode/decode works correctly my $regexp_raw = "...."; my $regexp_utf8_decoded = decode($some_enc, $regex_raw); my $regexp_utf8_encoded = encode('utf8', $regexp_utf8_decoded); my $some_content = "..."; my $some_content_decoded = decode($some_enc, $some_content); my $some_content_encoded = encode('utf8', $some_content_decoded); $some_content_decoded =~ /$regexp_utf8_decded/; # matches correctly $some_content_decoded =~ /$regexp_utf8_encoded/; # matches correctly $some_content_encoded =~ /$regexp_utf8_decoded/; # no $some_content_encoded =~ /$regexp_utf8_encoded/; # no

So why doesn't $some_content_encoded match? I thought all strings are normalized to UTF8...


In reply to Re^4: Matching UTF8 Regexps by lestrrat
in thread Matching UTF8 Regexps by lestrrat

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.