-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
swap_case doesn't correctly handle non-ASCII letters #3847
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
Comments
frankschmitt
added a commit
to frankschmitt/Python
that referenced
this issue
Oct 31, 2020
frankschmitt
added a commit
to frankschmitt/Python
that referenced
this issue
Oct 31, 2020
frankschmitt
added a commit
to frankschmitt/Python
that referenced
this issue
Nov 2, 2020
14 tasks
dhruvmanila
added a commit
that referenced
this issue
Nov 6, 2020
* #3847 fix handling of non-ASCII characters in swap_case * #3847 remove unused regex * Fix formatting (with black) Fixes: #3847 * Add type hints for `swap_case` function Co-authored-by: Frank Schmitt <[email protected]> Co-authored-by: Dhruv Manilawala <[email protected]>
stokhos
pushed a commit
to stokhos/Python
that referenced
this issue
Jan 3, 2021
…ms#3847) (TheAlgorithms#3848) * TheAlgorithms#3847 fix handling of non-ASCII characters in swap_case * TheAlgorithms#3847 remove unused regex * Fix formatting (with black) Fixes: TheAlgorithms#3847 * Add type hints for `swap_case` function Co-authored-by: Frank Schmitt <[email protected]> Co-authored-by: Dhruv Manilawala <[email protected]>
peRFectBeliever
pushed a commit
to peRFectBeliever/Python
that referenced
this issue
Apr 1, 2021
…ms#3847) (TheAlgorithms#3848) * TheAlgorithms#3847 fix handling of non-ASCII characters in swap_case * TheAlgorithms#3847 remove unused regex * Fix formatting (with black) Fixes: TheAlgorithms#3847 * Add type hints for `swap_case` function Co-authored-by: Frank Schmitt <[email protected]> Co-authored-by: Dhruv Manilawala <[email protected]>
Panquesito7
pushed a commit
to Panquesito7/Python
that referenced
this issue
May 13, 2021
…ms#3847) (TheAlgorithms#3848) * TheAlgorithms#3847 fix handling of non-ASCII characters in swap_case * TheAlgorithms#3847 remove unused regex * Fix formatting (with black) Fixes: TheAlgorithms#3847 * Add type hints for `swap_case` function Co-authored-by: Frank Schmitt <[email protected]> Co-authored-by: Dhruv Manilawala <[email protected]>
shermanhui
pushed a commit
to shermanhui/Python
that referenced
this issue
Oct 22, 2021
…ms#3847) (TheAlgorithms#3848) * TheAlgorithms#3847 fix handling of non-ASCII characters in swap_case * TheAlgorithms#3847 remove unused regex * Fix formatting (with black) Fixes: TheAlgorithms#3847 * Add type hints for `swap_case` function Co-authored-by: Frank Schmitt <[email protected]> Co-authored-by: Dhruv Manilawala <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The strings/swap_case implementation works only for ASCII letters (since it uses the incomplete regex [^a-zA-Z] to check whether a given characters is a letter). If you provide it with a non-ASCII letter, it will happily swap it and also return the unchanged version.
Example:
➜ strings git:(master) python3 swap_case.py
Please input sentence:This is broken: äü
tHIS IS BROKEN: ÄäÜü
The solution is pretty straightforward - it shouldn't use a regular expression at all, but rely on the built-in Python functions (as it partially already does).
The text was updated successfully, but these errors were encountered: