str.capitalize appears to uppercase the first character of the string, which is okay for ASCII but not for non-English letters.
For example, the letter NJ in Croatian appears as Nj at the start of words when the first character is capitalized:
Njemačka ('Germany'), not NJemačka.
(In ASCII, that's Njemacka not NJemacka.)
https://en.wikipedia.org/wiki/Gaj's_Latin_alphabet#Digraphs
But using any of:
U+01CA LATIN CAPITAL LETTER NJ
U+01CB LATIN CAPITAL LETTER N WITH SMALL LETTER J
U+01CC LATIN SMALL LETTER NJ
we get the wrong result with capitalize:
py> 'NJemačka'.capitalize()
'NJemačka'
py> 'Njemačka'.capitalize()
'NJemačka'
py> 'njemačka'.capitalize()
'NJemačka'
I believe that the correct behaviour is to titlecase the first code point and lowercase the rest, which is what the Apache library here does:
https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#capitalize-java.lang.String- |