On Wed, Oct 20, 2021 at 11:30:50AM +0900, Stephen J. Turnbull wrote:
> Steven D'Aprano writes:
> 
>  > Ironically, Ricky's in-fun suggestion that we use the tilde operator for 
>  > swapcase was the only suggestion in these two threads that actually met 
>  > the invariant for an inverse that ~~x == x.
> 
> You forgot about Turkish,

Yes I did, Turkish (and a couple of other Turkic languages) have dotted 
and dottless I, and their case rules differ from the default Unicode 
rules.


> I think it is, that has three cases (the
> third is called "title case".  Just another Joke that Broke because
> Unicode!

The Unicode titlecase algorithm is used for languages where digraphs 
like Lj, Nj, or Dz are classified as single letters of the alphabet. For 
example, the Polish word Dziewczyna uses the Dz digraph as the first 
letter. If you use the Unicode code point U+01F3 we get:

    'dziewczyna'.upper()  # returns 'DZIEWCZYNA'
    'dziewczyna'.title()  # returns 'Dziewczyna'

In case the glyphs don't show up for you, they are dz for the lowercase, 
DZ for the uppercase, and Dz for the titlecase.

swapcase() doesn't use titlecase. Titlecased characters remain 
unchanged when you use swapcase() on them.

-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/5IACCLOWHSAH7K5MPMQPX24K4KCWSCZW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to