Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Bogus locales on Mac (http://www.velocityreviews.com/forums/t333206-bogus-locales-on-mac.html)

Ellen Herzfeld 07-14-2004 07:44 PM

Bogus locales on Mac
 
I have been tearing my hair out trying to get Python to sort strings
containing accented characters according to the French locale settings
on Mac OS X (10.3).

I think I've done it correctly because on a Linux box it works...

What I find in the Mac's entrails is this:
/usr/share/locale/fr_FR.UTF-8 contains
LC_COLLATE -> ../la_LN.UTF-8/LC_COLLATE
LC_CTYPE -> ../la_LN.UTF-8/LC_CTYPE
LC_TIME
....

I checked some other locale directories and found the same link to
la_LN.UTF-8/LC_COLLATE, so whatever language you think you are
choosing, you are actually getting the same thing... I don't know what
la_LN is, maybe LATIN... The LC_COLLATE file in /la_LN.UTF-8 is 4642
bytes, the equivalent Linux file is 882134 bytes...

The date strings for the months are really in French in LC_TIME, and
using it does work correctly.

I tried using the Linux LC_COLLATE file on the Mac but it didn't work.

Has anyone using a Mac managed to sort accented strings correctly?

The Mac has mostly tried to be quite international so I'm surprised at
this. Have I missed something?

Thanks.

Ellen

--
-------------------------------------------------------------------
xlii@xlii.supprimer.org | Ellen C. Herzfeld
http://www.quarante-deux.org/ | Dominique O. Martel
Quelques pages sur la Science-Fiction | Quarante-Deux
-------------------------------------------------------------------

Michael Hudson 07-15-2004 11:18 AM

Re: Bogus locales on Mac
 
Ellen Herzfeld <xlii@xlii.supprimer.org> writes:

[snip]
> Has anyone using a Mac managed to sort accented strings correctly?
>
> The Mac has mostly tried to be quite international so I'm surprised at
> this. Have I missed something?


I suspect using some other method than the C libraries locale
functions is necessary... something like CFStringCompare? Dunno if
Python wraps that, though. Or maybe use PyObjC and NSSting's
-compare:options:range:locale: method.

HTH,
mwh

--
<dash> wow. this code does something highly entertaining, but
nowhere near correct -- from Twisted.Quotes

Ellen Herzfeld 07-15-2004 04:57 PM

Re: Bogus locales on Mac
 
In article <m33c3tr02d.fsf@pc150.maths.bris.ac.uk>, Michael Hudson
<mwh@python.net> wrote:

> I suspect using some other method than the C libraries locale
> functions is necessary... something like CFStringCompare? Dunno if
> Python wraps that, though. Or maybe use PyObjC and NSSting's
> -compare:options:range:locale: method.


I suppose there must be some way around the problem using Mac specific
code, but I need my scripts to be portable with minimum hassle. They
may have to run on a Linux or FreeBSD server...

I would like confirmation that I'm not missing something. Why would
Apple not use the standard C files for locales?

Ellen

--
-------------------------------------------------------------------
xlii@xlii.supprimer.org | Ellen C. Herzfeld
http://www.quarante-deux.org/ | Dominique O. Martel
Quelques pages sur la Science-Fiction | Quarante-Deux
-------------------------------------------------------------------

Ellen Herzfeld 07-16-2004 05:07 PM

Re: Bogus locales on Mac
 
In article <150720041857252245%xlii@xlii.supprimer.org>, Ellen Herzfeld
<xlii@xlii.supprimer.org> wrote:

> I suppose there must be some way around the problem using Mac specific
> code, but I need my scripts to be portable with minimum hassle. They
> may have to run on a Linux or FreeBSD server...
>
> I would like confirmation that I'm not missing something. Why would
> Apple not use the standard C files for locales?
>



Update:
The problem seems to be with the FreeBSD librairies for locales and not
with Apple. The sort problem is identical on FreeBSD 5.2.1. On Linux
(Mandrake) sorting is correct...

Ellen

--
-------------------------------------------------------------------
xlii@xlii.supprimer.org | Ellen C. Herzfeld
http://www.quarante-deux.org/ | Dominique O. Martel
Quelques pages sur la Science-Fiction | Quarante-Deux
-------------------------------------------------------------------


All times are GMT. The time now is 11:31 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.