Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unicode lc uc fc wtf
by Your Mother (Archbishop) on Sep 17, 2018 at 01:57 UTC | |
by jeffenstein (Hermit) on Sep 17, 2018 at 14:03 UTC | |
|
Re: unicode lc uc fc wtf
by choroba (Cardinal) on Sep 17, 2018 at 01:00 UTC | |
by Anonymous Monk on Sep 17, 2018 at 01:21 UTC |