[New-bugs-announce] [issue1995] localeconv() does not encode returned strings

Antoine Pitrou report at bugs.python.org
Fri Feb 1 19:13:48 CET 2008

New submission from Antoine Pitrou:

Some values in the dict returned by localeconv() may be non-ASCII
strings, yet they are not decoded according to the locale's character
set. This can be observed when the currency symbol is the euro sign:

>>> import locale
>>> locale.setlocale(locale.LC_MONETARY, 'fr_FR.UTF-8')
>>> locale.localeconv()['currency_symbol']
>>> locale.setlocale(locale.LC_MONETARY, 'fr_FR.ISO8859-15')
>>> locale.localeconv()['currency_symbol']

localeconv() is defined in the _locale module, which has no knowledge of
the current encoding - but the locale module does. So we could redefine
localeconv() in locale as a wrapper, to do the proper encoding dance.

components: Extension Modules
messages: 61970
nosy: pitrou
severity: normal
status: open
title: localeconv() does not encode returned strings
type: behavior
versions: Python 3.0

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list