perldoc -f fc says using lc to compare strings is
"Wrong!" and that uc is "Also wrong!" and that we
should use "fc" or a regex. Comparing lc, uc and fc
shows that only lc actually works, while uc fails,
and fc doesn't even exist. What's going on?
perl -le 'print $]'
5.028000
perl -CS -le 'print "\x{1e9e}"'
ẞ
perl -CS -le 'print lc "\x{1e9e}"'
ß
perl -CS -le 'print "\x{00df}"'
ß
perl -CS -le 'print uc "\x{00df}"'
ß
perl -CS -le 'print lc "\x{1e9e}" eq "\x{00df}" ? 1 : 0;'
1
perl -CS -le 'print "\x{1e9e}" eq uc "\x{00df}" ? 1 : 0;'
0
perl -CS -le 'print lc "\x{1e9e}" eq lc "\x{00df}" ? 1 : 0;'
1
perl -CS -le 'print uc "\x{1e9e}" eq uc "\x{00df}" ? 1 : 0;'
0
perl -CS -le 'print fc "\x{1e9e}" eq fc "\x{00df}" ? 1 : 0;'
String found where operator expected at -e line 1, near "fc "\x{00df}""
(Do you need to predeclare fc?)
syntax error at -e line 1, near "fc "\x{00df}""
Execution of -e aborted due to compilation errors.
perl -CS -le 'print fc("\x{1e9e}") eq fc("\x{00df}") ? 1 : 0;'
Undefined subroutine &main::fc called at -e line 1.
perldoc -f fc
fc EXPR
fc Returns the casefolded version of EXPR. This is the internal
function implementing the "\F" escape in double-quoted strings.
Casefolding is the process of mapping strings to a form where
case differences are erased; comparing two strings in their
casefolded form is effectively a way of asking if two strings
are equal, regardless of case.
Roughly, if you ever found yourself writing this
lc($this) eq lc($that) # Wrong!
# or
uc($this) eq uc($that) # Also wrong!
# or
$this =~ /^\Q$that\E\z/i # Right!
Now you can write
fc($this) eq fc($that)
And get the correct results.