in reply to Re: Normalizing diacritics in (regex) search
in thread Normalizing diacritics in (regex) search
Indeed, for string comparisons and substring searches, Unicode::Collate is the way to go.
use v5.40; use utf8; use open ':std', ':encoding(UTF-8)'; use Unicode::Collate qw( ); sub f { $_[0] < 0 ? "lt" : $_[0] > 0 ? "gt" : "eq" } my $s1 = "voilą"; # Canonical spelling my $s2 = "voila"; # Alternative spelling my $collator = Unicode::Collate->new( ignore_level2 => true ); my $cmp = $collator->cmp( $s1, $s2 ); say "$s1 ".( f( $collator->cmp( $s1, $s2 ) ) )." $s2";
voilą eq voila
Unfortunately for the OP, while Perl's regex engine can ignore case, it doesn't support ignoring diacritics.
|
|---|