http://qs321.pair.com?node_id=1104344


in reply to The Queensrÿche Situation

If you only have to deal with Unicode—and you properly should only have to deal with Unicode in this millennium—then use the Unicode collation algorithm instead of something non-standard. In Perl, this means using Unicode::Collate. Both the Unicode collation algorithm and the Perl CPAN module Unicode::Collate are customizable.

use strict; use warnings; # This Perl script is Unicode UTF-8 use utf8; # Proper Unicode collation use Unicode::Collate; # The output of this Perl script is Unicode UTF-8 binmode STDOUT, ':encoding(UTF-8)'; my $fancy = 'Queensrÿche'; my $plain = 'Queensryche'; my $collator = Unicode::Collate->new( level => 1, normalization => undef, ); # This prints "Queensrÿche and Queensryche are the same word." printf "$fancy and $plain %s the same word.\n", $collator->eq($fancy, $plain) ? "are" : "aren't"; exit 0;

As it says in the script, this correctly prints "Queensrÿche and Queensryche are the same word." Whether or not this is exactly what's displayed in your terminal window is another matter altogether—one that's not related to the Perl script.

See Perl Unicode Cookbook: Case- and Accent-insensitive Comparison by Tom Christiansen (tchrist).

Update:  By the way, in this same configuration of Unicode::Collate, the strings "QUEENSRŸCHE" and "Queensryche" will compare equal as well.