-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str.capitalize should titlecase the first character not uppercase #80730
Comments
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 we get the wrong result with capitalize: py> 'NJemačka'.capitalize() 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: |
I think this is a reasonable change. Also the docs for str.title() should be fixed. |
Hello there, I'm an absolute beginner here and this whole thing is a little overwhelming, so please bear with me. I think this would be a suitable first task for me to take on because it appears to be a simple one-line change (correct me if I'm mistaken, though). |
This issue is easy if you know C.
|
Thanks for clarifying all of that! I now have the patch and tests working locally. However, I'm not too sure what documentation needs to be changed for str.title. Should it specify that only the first letter of digraphs are capitalised, rather than the full character? |
Thanks! I'm a big fan of this change :) |
I think that the PR may have been merged too quickly. Serhiy had made a list, and I think that the PR was missing some necessary changes. |
What is missing? It looks like everything on Serhiy's list was done. |
Oh, apart from the What's New section. But this looks enough like a bugfix (previous behaviour "wasn't capitalizing my name correctly" - new behaviour "now capitalizes my name correctly") that it's hardly critical to advertise it on that page. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: