Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Perl 5.16 fc()

by OlegG (Monk)
on May 22, 2012 at 09:21 UTC ( [id://971743]=perlquestion: print w/replies, xml ) Need Help??

OlegG has asked for the wisdom of the Perl Monks concerning the following question:

Is it true, that result of fc($a) eq fc($b) will be the same as lc(uc($a)) eq lc(uc($b)) ?
Any counterexample?

Replies are listed 'Best First'.
Re: Perl 5.16 fc()
by daxim (Curate) on May 22, 2012 at 10:39 UTC
    First is false, second is true.
    perl -Mutf8 -E'say lc(uc("\N{LATIN CAPITAL LETTER SHARP S}")) eq lc(uc("SS"))' perl -Mutf8 -E'say fc("\N{LATIN CAPITAL LETTER SHARP S}") eq fc("SS")'
      LATIN CAPITAL LETTER SHARP S
      uc("ẞ") ⇒ "ẞ"   (LATIN CAPITAL LETTER SHARP S)
      lc("ẞ") ⇒ "ß"   (LATIN SMALL LETTER SHARP S)
      fc("ẞ") ⇒ "ss"
      
      LATIN SMALL LETTER SHARP S
      uc("ß") ⇒ "SS"  ←
      lc("ß") ⇒ "ß"   (LATIN SMALL LETTER SHARP S)
      fc("ß") ⇒ "ss"
      
      uc("SS") ⇒ "SS"
      lc("SS") ⇒ "ss"
      fc("SS") ⇒ "ss"
      
      uc("ss") ⇒ "SS"
      lc("ss") ⇒ "ss"
      fc("ss") ⇒ "ss"
      

      If you reverse the uc and the lc, the two expressions will be equivalent for this example, but I don't know if it holds for all cases, and it's not something you should count on.

      Really, thanks
Re: Perl 5.16 fc()
by moritz (Cardinal) on May 22, 2012 at 09:41 UTC
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://971743]
Approved by moritz
Front-paged by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-16 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found