When would you ever need to use fc()
, when would uc()
ever fail?
Perl fc documentation
fc
is used for case-insensitive comparisons.
uc($a) cmp uc($b) # XXX
lc($a) cmp lc($b) # XXX
fc($a) cmp fc($b) # ok
An example where this makes a difference:
lc uc fc
-- -- -- --
ss ss SS ss
SS ss SS ss
ß ß SS ss
ẞ ß ẞ ss
Notice that fc("ß") eq fc("ẞ"), but uc("ß") ne uc("ẞ").
Notice that fc("ß") eq fc("ss"), but lc("ß") ne lc("ss").
The table was generated using
use strict;
use warnings;
use feature qw( fc );
use open ':std', ':encoding(UTF-8)';
my $ss = "\N{LATIN SMALL LETTER SHARP S}";
my $SS = "\N{LATIN CAPITAL LETTER SHARP S}";
printf(" lc uc fc\n");
printf("-- -- -- --\n");
printf("%-2s %-2s %-2s %-2s\n", $_, lc($_), uc($_), fc($_))
for 'ss', 'SS', $ss, $SS;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With