On 09/02/2015 15:43, Albert-Jan Roskam wrote:
Hi,

In the locale module we have:
* setlocale, the setter that also returns something
* getlocale, the getter that returns the OS-specific locale tuple (supposedly!)

* getdefaultlocale, the getter that always returns a unix locale tuple

Why are the getlocale() results below sometimes windows-like, sometimes 
unix-like?
It seems that I need to use setlocale(), with only the 'category' parameter, 
right?


ActivePython 3.3.2.0 (ActiveState Software Inc.) based on
Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
import locale
locale.getlocale()
(None, None)   # because setocale has not been called yet


# works as expected

locale.setlocale(locale.LC_ALL, "")
'Dutch_Netherlands.1252'
locale.getlocale()
('Dutch_Netherlands', '1252')

# bug!>>> locale.setlocale(locale.LC_ALL, "german")
'German_Germany.1252'
locale.getlocale()
('de_DE', 'cp1252')     # incorect, unix-like!


locale.setlocale(locale.LC_ALL, "German_Germany.1252")
'German_Germany.1252'
locale.getlocale()
('de_DE', 'cp1252')     # incorect, unix-like!


# bug!

locale.setlocale(locale.LC_ALL, "spanish")
'Spanish_Spain.1252'
locale.getlocale()
('es_ES', 'cp1252')   # incorect, unix-like!


# works as expected
locale.setlocale(locale.LC_ALL, "italian")
'Italian_Italy.1252'
locale.getlocale()
('Italian_Italy', '1252')    # correct!


# ... maybe more?


Regards,

Albert-Jan


There have been loads of bug reports on the issue tracker about locales. I suggest that you take a look to see if there is an open issue about this problem.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a

fresh water system, and public health, what have the Romans ever done for us?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Those flaming Romans didn't get the locales right did they? :)

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to