LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 07-30-2003, 02:54 PM   #1
TheLinuxDuck
Member
 
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?

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

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
TheLinuxDuck
Member
 
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
jippo
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 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

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 04:56 AM.

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