Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > General
User Name
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!


Search this Thread
Old 07-30-2003, 02:54 PM   #1
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
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?

Old 07-30-2003, 04:44 PM   #2
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 63
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
Old 07-31-2003, 09:04 AM   #3
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Original Poster
Rep: Reputation: 33
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. (=
Old 03-02-2006, 03:06 AM   #4
LQ Newbie
Registered: Mar 2006
Location: Vladivostok
Posts: 7

Rep: Reputation: 0
Lightbulb 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
PHP Code:

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

=`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
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 
./ cp1251
./ koi8r
./ utf8

Via Perl Create executable
PHP Code:

# Usage: ./ codepage

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

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


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";} 
./ koi8-r
./ koi8r
./ cp1251

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

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


$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

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

Last edited by jippo; 03-02-2006 at 09:27 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl: warning: Falling back to the standard locale ("C"). walterbyrd Debian 11 05-14-2009 08:50 AM
"locale not supported by Xlib, locale set to C" Irad Linux - Software 3 06-25-2006 03:59 PM
CUPS: "This server could not verify that you are authorized to use this resrouce" hamish Linux - Software 0 07-02-2004 03:57 AM
cupsd, many "modprobe: can't locale device /dev/usbxx" at boot.. bit7 Linux - Software 0 01-16-2004 01:40 AM
What is correct code for "Include File Function" on .asp pages gregoryfrancis Linux - General 1 02-11-2003 10:49 PM

All times are GMT -5. The time now is 01:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration