LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   How do I verify my locale information is "correct"? (https://www.linuxquestions.org/questions/general-10/how-do-i-verify-my-locale-information-is-correct-77388/)

TheLinuxDuck 07-30-2003 02:54 PM

How do I verify my locale information is "correct"?
 
hey all!

I'm running a heavily modified slackware 8.1 distro. While trying to compile a program, I'm getting an error with the en_US (I assume that it's saying it can't find it) locale setting. It does exist, but I'm not sure if there's something I need to do to make sure that the locale settings are as they should be, or if there's a locale.cache file that needs to be updated or something.. I'm running an older version of glibc (2.1.3) and would like to upgrade it, but that makes me nervous.. (=

Any knowledge to share? Any questions aboot my system?

TLD

Blinker_Fluid 07-30-2003 04:44 PM

locale at a prompt tells you locale-specific information.
If something isn't right you might want to look at localedef...
Other than that I haven't messed with it...
Good luck

TheLinuxDuck 07-31-2003 09:04 AM

BF: I appreciate the reply. I've already tested and checked everything of which I can think, including the env setting for locale (as verified by running locale).

Part of the troubles, I fear, are that I did some system consolidation of duplicate directories (such as the items in /usr/shared), which happens to include the locale information.

See, I compiled and installed a newer version of glibc, but to a non-standard location, so as to preserve my older version.. and in doing so, I changed the existing locale information to duplicate the new locale information in the new glibc install dir. I think this of itself is the reason why it's broken. I was toying with what I didn't fully understand. (=

I tend to do this, so it's not surprising to me I broke something. (=

jippo 03-02-2006 03:06 AM

If you want to test locale...
 
(better late than never :) )

My system: SuSE 10.0, kernel 2.6.13, KDE 3.4, bash 3.00, locales ru_RU.UTF-8, ru_RU.koi8r, ru_RU.cp1251

Assume you are in ru_RU.UTF-8 and want to verify either ru_RU.koi8r or ru_RU.cp1251 installed

Via bash. Create executable test-locale.sh
PHP Code:

#!/bin/bash

if [ "$#" != ] ; then echo "Usage: $0 charmap"; exit; fi
if ! locale -fgrep -$1then echo "Unknown charmap"; exit 1fi
if ! rpm -qa fgrep -q recodethen echo "recode utility not found"; exit 2fi

CHR1
=`echo А | recode ..$1/ 2> /dev/null# 1st national letter in upper case
CHR2=`echo Я | recode ..$1/ 2> /dev/null# last national letter in upper case
CHR3=`echo Ё | recode ..$1/ 2> /dev/null# any national letter in upper case that is inside range [CHR1-CHR2] lexically, but out of in ASCII (C or POSIX locale)
DATE=`echo Января | recode ..$1/ 2> /dev/null# "January" word's national equivalent cased accordingly
LANG=ru_RU.$1
if [[ "$CHR3== [[:upper:]] ]] ; then echo "LC_CTYPE is OK" ; else echo "LC_CTYPE is broken" fi
if [[ "$CHR3== [${CHR1}-${CHR2}] ]] ; then echo "LC_COLLATE is OK" ; else echo "LC_COLLATE is broken" fi
if [ "$DATE== "`date -d \"Jan 1 2000\" +\"%B\"`" ] ; then echo "LC_TIME is OK" ; else echo "LC_TIME is broken" fi 

Try:
./test-locale.sh cp1251
./test-locale.sh koi8r
./test-locale.sh utf8

Via Perl Create executable test-locale.pl
PHP Code:

#!/usr/bin/perl

# Usage: ./test-locale.pl codepage

use locale;
use 
POSIX qw (setlocale LC_ALL);
use 
POSIX qw (strftime);
use 
Unicode::Map8;
use 
Unicode::String qw (utf8);

if (
!= $ARGV[0]) {print "Usage: test-locale.pl codepage\n"; exit;}

$codepage=$ARGV[0];

my $str Unicode::Map8 -> new ($codepage);
$uc_ch $str->to8 (utf8 ("П") -> utf16); // any national letter in upper case
$lc_ch $str->to8 (utf8 ("п") -> utf16); // the same letter in lower case
$month $str->to8 (utf8 ("Января") -> utf16); // "January" word's national equivalent cased accordingly

print setlocale (LC_ALL"ru_RU." $codepage) . "\n";

if (
$uc_ch ne $lc_ch && $uc_ch == uc ($lc_ch)) {print "LC_CTYPE is OK\n";} else {print "LC_CTYPE is broken\n";}
if (
$month == strftime ("%B"000100)) {print "LC_TIME is OK\n";} else {print "LC_TIME is broken\n";} 

Try:
./test-locale.pl koi8-r
./test-locale.pl koi8r
./test-locale.pl cp1251

Via PHP. Create executable test-locale.php
PHP Code:

#!/usr/bin/php

<?
if (!= $argc) {exit ("Usage: test-locale.php codepage\n");}

$codepage=$argv[1];

$uc_ch mb_convert_encoding ("П"$codepage"UTF-8"); // any national letter in upper case
$lc_ch mb_convert_encoding ("п"$codepage"UTF-8"); // the same letter in lower case
$month mb_convert_encoding ("Января"$codepage"UTF-8"); // "January" word's national equivalent cased accordingly

print setlocale (LC_ALL"ru_RU." $codepage) . "\n";

if (
$uc_ch !== $lc_ch && $uc_ch === strtoupper ($lc_ch)) {print "LC_CTYPE is OK\n";} else {print "LC_CTYPE is broken\n";}
if (
$month === strftime ("%B"strtotime("1 January 2000"))) {print "LC_TIME is OK\n";} else {print "LC_TIME is broken\n";}
?>

Note: to test UTF8 check "mbstring.func_overload" php.ini option

Try:
./test-locale.php koi8-r
./test-locale.php koi8r
./test-locale.php cp1251
./test-locale.php utf8


All times are GMT -5. The time now is 09:22 AM.