Message207026
>>> import locale, _locale
>>> _locale.setlocale(locale.LC_CTYPE, 'en_AG')
'en_AG'
>>> _locale.setlocale(locale.LC_CTYPE)
'en_AG'
>>> locale.getlocale(locale.LC_CTYPE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/locale.py", line 575, in getlocale
return _parse_localename(localename)
File "/home/serhiy/py/cpython/Lib/locale.py", line 484, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: en_AG
One solution is proposed in issue20079: map all supported in glibc locale names without encoding to locale names with encoding. But see issue20087. And default encoding can be different on other systems (not based on glibc).
Other solution is not guess an encoding, but use locale.nl_langinfo(locale.CODESET) in locale.getlocale(). And left in locale alias table only nonstandard mappings (such as english_uk -> en_GB.ISO8859-1 and sr_yu.iso88595 -> sr_CS.ISO8859-5). |
|
Date |
User |
Action |
Args |
2013-12-28 09:44:03 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, lemburg, loewis |
2013-12-28 09:44:02 | serhiy.storchaka | set | messageid: <1388223842.98.0.521951916148.issue20088@psf.upfronthosting.co.za> |
2013-12-28 09:44:02 | serhiy.storchaka | link | issue20088 messages |
2013-12-28 09:44:02 | serhiy.storchaka | create | |
|