Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Regex Matching Unicode and Regex Classes

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


in reply to Re^2: Regex Matching Unicode and Regex Classes
in thread Regex Matching Unicode and Regex Classes

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).


Comment on Re^3: Regex Matching Unicode and Regex Classes
Re^4: Regex Matching Unicode and Regex Classes
by McA (Priest) on Nov 02, 2011 at 14:48 UTC
    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
    Andreas

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (15)
As of 2015-07-07 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (90 votes), past polls