# lc and uc turn a string into another string; they are not a way to compare
# two strings regardless of case. fc -- "fold case", `use v5.16` and later --
# is. Some letters change length on the way, one Greek letter has two lower-case
# forms, and no language's own rules apply.
use v5.36;
use utf8;

binmode STDOUT, ':encoding(UTF-8)';

sub yn { $_[0] ? 'yes' : 'no' }    # no signature: a failed match in an argument list passes nothing

say "--- lc, uc and fc ---";
for my $word ('Straße', 'STRASSE', 'σας', 'ΣΑΣ', 'İstanbul') {
    say "  $word:  lc ", lc $word, "  uc ", uc $word, "  fc ", fc $word;
}
say "";

say "--- comparing ---";
say "  lc('Straße') eq lc('STRASSE')   ", yn(lc('Straße') eq lc('STRASSE'));
say "  fc('Straße') eq fc('STRASSE')   ", yn(fc('Straße') eq fc('STRASSE'));
say "  lc('σας') eq lc('ΣΑΣ')          ", yn(lc('σας') eq lc('ΣΑΣ'));
say "  fc('σας') eq fc('ΣΑΣ')          ", yn(fc('σας') eq fc('ΣΑΣ'));
say "  'STRASSE' =~ /^straße\$/i        ", yn('STRASSE' =~ /^straße$/i);
say "";

say "--- lengths change ---";
say "  length 'ß' = ", length('ß'), ", length uc 'ß' = ", length(uc 'ß');
say "  length 'İ' = ", length('İ'), ", length lc 'İ' = ", length(lc 'İ'),
    "  (", join(' ', map { sprintf 'U+%04X', ord } split //, lc 'İ'), ")";
say "";

say "--- title case is a third case ---";
say "  ucfirst 'ǆungla' = ", ucfirst('ǆungla'), sprintf("  (U+%04X)", ord ucfirst 'ǆ'),
    ", uc 'ǆungla' = ", uc('ǆungla'), sprintf("  (U+%04X)", ord uc 'ǆ');
say "";

say "--- one mapping for every language ---";
say "  lc 'I' = ", lc('I'), sprintf("  (U+%04X)", ord lc 'I'), "   Turkish lower-cases I to ı, U+0131";
