3 ms·
Looks like it's no longer the case in Python 3: Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits
by jwilk 6y ago
Looks like it's no longer the case in Python 3:
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from locale import *
>>> setlocale(LC_ALL, 'tr_TR.UTF-8')
'tr_TR.UTF-8'
>>> 'INFO'.lower()
'info'
- xyst 6y agoPython 3.7.5 (default, Nov 5 2019, 22:30:48) [Clang 11.0.0 (clang-1100.0.33.12)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from locale import * >>> setlocale(LC_ALL, 'tr_TR.UTF-8') 'tr_TR.UTF-8' >>> 'INFO'.lower() 'info' >>> '🧘 ️'.lower() '🧘\u200d️' >>> exit() There's something wrong with emojis + lower() though
- Dylan16807 6y agoIt lowercased the 'show this as emoji' variation selector to zero width joiner?
- anderskaseorg 6y agoOddly, it also wasn’t the case for Python 2 Unicode strings (u'INFO'), only for Python 2 byte strings ('INFO'). So it’s possible that Python 3 lost this behavior by accident.
- price 6y agoOn some more digging through history, it looks like the change in behavior for byte strings was intentional: https://github.com/python/cpython/commit/6ccd3f2dbcb98b33a71ffa6eae949deae797c09c https://github.com/python/cpython/commit/6ccd3f2dbcb98b33a71... Author: Guido van Rossum <guido@python.org> Date: Tue Oct 9 03:46:30 2007 +0000 Replace all (locale-dependent) uses of isupper(), tolower(), etc., by locally-defined macros that assume ASCII and only consider ASCII letters.