fc

fc EXPR
fcNew to v5.16 where it is enabled by use feature "fc", this function returns the
full Unicode casefold of EXPR. This is the
internal function implementing the \F
escape in casefolded strings. Just as titlecase is based on uppercase
but different, foldcase is based on lowercase but different. In ASCII
there is a one-to-one mapping between only two cases, but in Unicode
there is a one-to-many mapping and between three cases. Because that’s
too many combinations to check manually each time, a fourth casemap
called foldcase was invented as a common intermediary for the other
three. It is not a case itself, but it is a
casemap.
To compare whether two strings are the same without regard to case, do this:
fc($a) eq fc($b)
Prior to v5.16, the only reliable way to compare strings
case-insensitively was with the /i
pattern modifier, because Perl has always used casefolding semantics for
case-insensitive pattern matches. Knowing this, you can emulate equality
comparisons like this:
sub fc_eq($$) {
my($a, $b) = @_;
return $a =~ /\A\Q$b\E\z/i;
}For earlier releases than v5.16, the fc function can be found in the Unicode::CaseFold module on CPAN. For comparisons that are both accent- and
case-insensitive, use the eq or
cmp methods with a Unicode::Collate collator object that was passed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access