This language bar is your friend. Select your favorite languages!

Idiom #213 Case-insensitive string compare

Compare four strings in pair-wise variations. The string comparison can be implemented with an equality test or a containment test, must be case-insensitive and must apply Unicode casefolding.

This idiom task is intended to supplant #133 which suffers from massive quality problems.

use utf8;
use Test::More;
my @strings = ('ᾲ στο διάολο', 'ὰι στο διάολο', 'Ὰͅ ΣΤΟ ΔΙΆΟΛΟ', 'ᾺΙ ΣΤΟ ΔΙΆΟΛΟ');
my @indices = (
    [0,1], [0,2], [0,3],
    [1,0], [1,2], [1,3],
    [2,0], [2,1], [2,3],
    [3,0], [3,1], [3,2]
);
for my $tuple (@indices) {
    ok $strings[$tuple->[0]] =~ qr"\Q$strings[$tuple->[1]]"i;
}
done_testing;
import itertools
strings = ['ᾲ στο διάολο', 
           'ὰι στο διάολο', 
           'Ὰͅ ΣΤΟ ΔΙΆΟΛΟ', 
           'ᾺΙ ΣΤΟ ΔΙΆΟΛΟ']

for a, b in itertools.combinations(strings, 2):
    print(a, b, a.casefold() == b.casefold())
strings = ['ᾲ στο διάολο', 'ὰι στο διάολο', 'Ὰͅ ΣΤΟ ΔΙΆΟΛΟ', 'ᾺΙ ΣΤΟ ΔΙΆΟΛΟ']

strings.combination(2){|a,b| puts "#{a} equals #{b}: #{a.casecmp?(b)}" }

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

daxim