about locale-naming conformace checking

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

about locale-naming conformace checking

Luis Peña
Hello,

I'm doing a c program where I should know whether a
set of strings, coming from a directory listing in
this case, contains correctly named locale
directories.

I'm just using the two letters for language code, plus
the other two for the region code, like this: `es_ES'.
 Thus, without any codeset or modifiers.

The thing is that by grasping for example
/usr/bin/locale source code, or the setlocale
function, it seems there is no way I can have access
to the arrays iso-639-1 and ISO 3166-2. Still I might
need to study /usr/bin/locale so as to know how it's
done so strings like `es_GB' aren't accepted as valid.

My question is how to check that a string is valid
against the locale data libc has? Either I'm missing
some function or there's no way of doing this, in
which case I'd like somebody to tell me how to
proceed.

Ways (very clumsy) I though of include: copying the
related iso definitions file, plus the interface
needed to make that work,
which is a shame cose libc has already have that
information on host's memory.

Other solution I though is temporally changing the
locale and seeing what setlocale returns, but it looks
clumsy to me as well. In the case such a function
returns NULL, there's no way of knowing wheter it did
because actual locale wasn't available on user's host
(actually the data it needs to be set), or because the
string is invalid as a locale name.

I can't either see nothing helpful within langinfo.h,
so I'd really appreciate if somebody could shred some
light on this.

Regards,



       
____________________________________________________________________________________
Sé un Mejor Amante del Cine                        
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!
http://advision.webevents.yahoo.com/reto/entretenimiento.html