Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Regex Matching Unicode and Regex Classes

by moritz (Cardinal)
on Nov 02, 2011 at 14:08 UTC ( #935405=note: print w/replies, xml ) Need Help??

in reply to Regex Matching Unicode and Regex Classes

The default Unicode semantics just check the Unicode properties of a codepoint. "" is U+00E4 LATIN SMALL LETTER A WITH DIAERESIS and classified as a letter, so \w matches it.

  • Comment on Re: Regex Matching Unicode and Regex Classes

Replies are listed 'Best First'.
Re^2: Regex Matching Unicode and Regex Classes
by McA (Priest) on Nov 02, 2011 at 14:27 UTC
    Hi Moritz,

    but what is then the difference to the third case? Is the "default Unicode semantic" changed to something different when local is enabled?

    Why is "U+00E4 LATIN SMALL LETTER A WITH DIAERESIS" under locale something different than a letter which is part of a word?

    Best regards

      Short answer: because Unicode and locales don't mix.

      Long answer: Perl's support for locales comes from a time before the whole encoding/decoding business and Unicode support. So if locales are active, the locale-sensitive parts expect to act on bytes, not on decoded strings.

      Since the locale is not ISO-8859-1 but UTF-8, encoding to Latin-1 doesn't fix it for you.

      If anything, you'd need to encode to UTF-8 to see the \w matching , but even then I don't see it matching. So either my understanding of locales is very wrong, or perl is broken (or a mixture thereof).

        Hi Moritz,

        that sounds plausible, but not satisfying. ;-)

        What is then the right approach to find word boundaries with regex while locale is enabled?

        Best regards

Re^2: Regex Matching Unicode and Regex Classes
by McA (Priest) on Nov 02, 2011 at 15:00 UTC

    thanky ou for your answers.
    Have a nice day.

    Best regards

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935405]
[erix]: oh well, it's holy week, right? Thick-skin week. I just read that in the Philippines, some RCs practice self-crucifixion. Tough cookies I'd like to see
[LanX]: already?
[erix]: I don't know really. I thought so.
[LanX]: April 16th
[erix]: ah no, 16 april. some time to go yet :)
[LanX]: I hate resurrection ... my back aches
erix practices self-crucifixion but keeps getting get stuck at the one loose hand stage...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-03-23 08:59 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (285 votes). Check out past polls.