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

Re: international case insensitive searched with Perl

by Anonymous Monk
on Oct 03, 2011 at 19:53 UTC ( #929412=note: print w/ replies, xml ) Need Help??


in reply to international case insensitive searched with Perl

#!perl use 5.014; use warnings; my $string = 'LÉGER'; print $string =~ /léger/i ? 'matched' : 'no match';

Prints 'matched' for me.

... of course if you're using an older version of perl, you need to put a little more work into enforcing a match under Unicode rules.

TJD


Comment on Re: international case insensitive searched with Perl
Download Code
Re^2: international case insensitive searched with Perl
by Anonymous Monk on Oct 03, 2011 at 20:05 UTC
    More info:

    use feature 'unicode_strings' is the magic that works in 5.14.

    Check out 'The "Unicode Bug"' in  perldoc perlunicode

    TJD

Re^2: international case insensitive searched with Perl
by chrestomanci (Priest) on Oct 04, 2011 at 09:13 UTC
Re^2: international case insensitive searched with Perl
by mwhiting (Beadle) on Oct 04, 2011 at 15:57 UTC
    What kind of extra work is involved to make it match under unicode rules? I'm guessing it's a bit, so I might end up doing an customer-specific workaround to deal with it for them.
      use feature 'unicode_strings' tells perl to assume all strings are unicode.

      use utf8 tell perl to assume all strings in the current source file are unicode.

      Opening input files with a  :encoding layer will tell perl that the resulting strings are unicode.

       use encode contains subs that can be used to mark or convert strings from any other source as/to unicode.

      Hope this helps

      TJD

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (18)
As of 2015-07-07 14:46 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 (89 votes), past polls