Portable locale usage

ssegvic sinisa.segvic at fer.hr
Wed Sep 7 07:17:52 EDT 2011

On 6 ruj, 17:53, Thomas Jollans <t... at jollybox.de> wrote:
> On 06/09/11 16:46, ssegvic wrote:
> > For the moment, I only wish to properly sort a Croatian text file
> > both on Windows and Linux (I am a cautious guy, I like reachable
> > goals).
> > When the locale is properly set, sorting works like a charm
> > with mylist.sort(key=locale.strxfrm).
> The problem with that is of course that a Croatian locale has to be
> installed. Many Linux systems don't have locales that aren't used.

I already concluded that on Linux there are no problems whatsoever
(the Croatian locale was kindly installed by the distribution setup).

Since my initial snippet does not work on Windows, I would conclude
that the locale aliasing engine on Windows should be improved.

Any opposing views will be appreciated :-)

For convenience, I repeat the snippet here:
import locale
locale.setlocale(locale.LC_ALL, ('hr', locale.getpreferredencoding()))



More information about the Python-list mailing list