String comparison: Difference between revisions

Content added Content deleted
(→‎{{header|Raku}}: beware to normalization by default)
(→‎{{header|Raku}}: add a String comparison example for the normalization trap)
Line 3,609: Line 3,609:
say "\c[KELVIN SIGN]".uniname;
say "\c[KELVIN SIGN]".uniname;
# => LATIN CAPITAL LETTER K
# => LATIN CAPITAL LETTER K

my $kelvin = "\c[KELVIN SIGN]";
my $k = "\c[LATIN CAPITAL LETTER K]";
say ($kelvin eq $k); # True, lexically equal
say ($kelvin eqv $k); # True, generically equal
say ($kelvin === $k); # True, identical objects
</syntaxhighlight>
</syntaxhighlight>

In most programming language the previous two objects wouldn't be equivalent but in Raku there are since normalization is applied by default automatically and can't be disabled.


It's officially identified as a common trap for string handling<ref>https://docs.raku.org/language/traps#All_text_is_normalized_by_default</ref>.
It's officially identified as a common trap for string handling<ref>https://docs.raku.org/language/traps#All_text_is_normalized_by_default</ref>.