Bogus locales on Mac

E

Ellen Herzfeld

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

--
 
M

Michael Hudson

[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:eek:ptions:range:locale: method.

HTH,
mwh
 
E

Ellen Herzfeld

Michael Hudson said:
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:eek:ptions: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

--
 
E

Ellen Herzfeld

Ellen Herzfeld said:
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

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top