Created
August 22, 2023 15:37
-
-
Save ydm/2f2e6a60887d78881be78703df38e7a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PyDoc_STRVAR_shared(_Py_title__doc__, | |
| "B.title() -> copy of B\n\ | |
| \n\ | |
| Return a titlecased version of B, i.e. ASCII words start with uppercase\n\ | |
| characters, all remaining cased characters have lowercase."); | |
| void | |
| _Py_bytes_title(char *result, const char *s, Py_ssize_t len) | |
| { | |
| Py_ssize_t i; | |
| int previous_is_cased = 0; | |
| for (i = 0; i < len; i++) { | |
| int c = Py_CHARMASK(*s++); | |
| if (Py_ISLOWER(c)) { | |
| if (!previous_is_cased) | |
| c = Py_TOUPPER(c); | |
| previous_is_cased = 1; | |
| } else if (Py_ISUPPER(c)) { | |
| if (previous_is_cased) | |
| c = Py_TOLOWER(c); | |
| previous_is_cased = 1; | |
| } else | |
| previous_is_cased = 0; | |
| *result++ = c; | |
| } | |
| } |
ydm
commented
Aug 22, 2023
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment