Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Sep 2000 18:52:03 +0400
From:      "Alexander Voropay" <a.voropay@globalone.ru>
To:        <i18n@FreeBSD.ORG>
Subject:   Re: Request for review: locale aliases support for libc
Message-ID:  <34d701c01424$4a2e4b60$cd0d11ac@host205.spb.in.rosprin.ru>

next in thread | raw e-mail | index | archive | help
Alexey Zelkin <phantom@cris.crimea.ua> wrote:

>I am trying to realize "is requested locale physicaly present on this system"
>or it's just an alias. Currently I am just testing presence of 
>/usr/share/locale/$requested_locale/LC_CTYPE and make decision depends
>on stat(2) return value.


 AFAIK, the presense of any forms of locale "aliasing" does not
comply current POSIX specifications :
  string=setlocale(LC_xxx, "language_TERRITORY.Codeset");
should returns _THE_SAME_ locale name _as requested_.

 Try this on "aliased" and "non aliased" locales.
(JFYI: It fails on any "aliased" locales on glibc2.)

==lct.c======
#include <stdio.h>
#include <locale.h>
#include <string.h>

main (int argc, char *argv[]) {

char * reqlcname;
char * gotlcname;

if (argc != 2){
  printf("Usage: lct language[_TERRITORY[.Codeset]]\n");
  exit (1);
  };
reqlcname=argv[1];

printf("Trying to set LC_CTYPE=%s\n",reqlcname);

gotlcname=setlocale(LC_CTYPE, reqlcname);  /* ALL MAGIK IS HERE */

if ( !gotlcname) {
  printf ("There is no locale '%s' in your system.\n",reqlcname);
  exit (1);
  }
else {
  printf("I've got LC_CTYPE=%s\n",gotlcname);

  if ( strcmp(gotlcname, reqlcname))
    printf("I can't set REQUIRED locale !\n");
  else
    printf("Great! All OK.\n");
  };
}
=============

--
-=AV=-



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-i18n" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?34d701c01424$4a2e4b60$cd0d11ac>