Sponsored Content
Operating Systems AIX Undestanding LANG setting in /etc/environment Post 302778249 by bakunin on Sunday 10th of March 2013 07:56:12 AM
Old 03-10-2013
Quote:
Originally Posted by Don Cragun
Setting LANG=C will do what Aaron Boyce wants only if neither LC_ALL nor LC_NUMERIC is set in the environment. LC_NUMERIC will override LANG for purposes of determining the radix character used and the formatting of numeric output. LC_ALL will override both LANG and LC_NUMERIC.

If LC_NUMERIC is effectively set to a value that sets non-null thousands separators or that uses comma as the radix character, you need to take extra precautions when working with CSV files that contain numeric strings that represent non-integral values, or integral values greater than 999 or less than -999.
You are right, Don, as always. In his entry posting Aaron stated that his SysAdmin has traced back the problem to the changed LANG-entry in /etc/environment, so i took it that none of the applicable LC_-variables are defined in his case, because these would have overridden the old as well as the new setting.

Still, its a good idea to explain the interdependence of LANG and LC_ALL the other LC_-variables.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setting up Environment Variables

Hi all, I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all. here is what i am trying to do : JAR_HOME=/home/was5/bdcms/scheduledjobs/lib export... (6 Replies)
Discussion started by: rpandey
6 Replies

2. UNIX for Dummies Questions & Answers

Setting the $LANG info needed

Hello (Very New to UNIX -Solaris 10) I'm trying to set the LANG variable to C but not sure if it's getting set, need some help on this. Currently I have it set to en_GB.UTF-8 I need to set it to C for an install. but when I run set LANG=C and then run echo $LANG its still set to... (2 Replies)
Discussion started by: deedaz
2 Replies

3. UNIX for Advanced & Expert Users

sudo environment setting?

Hi, first post. As the nick suggests I'm a Unix noob, but I'm doing everything I can to learn fast...job requirement. These forums have been a huge help so far. I have a server running HP-UX 11.23b with Apache/2.0.59 HP-UX_Apache-based_Web_Server. Apache is not installed in the default... (3 Replies)
Discussion started by: nixnoob
3 Replies

4. Programming

Setting Environment variable..!

Hi, I already have one CPP program which invokes the C program.And the C program contains whole function definitions..!This is a working program..I have to enable the logs in both CPP as well as in the C program ..!So I am reading the enviornmental variable log path from the CPP and doing the... (2 Replies)
Discussion started by: Kattoor
2 Replies

5. UNIX for Dummies Questions & Answers

Setting up your environment

Hi I am new to Solaris and was just given my id and need to setup my environment, what do i need to do to run certain commands without putting in the complete path. How do I create my .profile, I do not see under my login? Any help would be greatly appreciated. (5 Replies)
Discussion started by: sa_ken
5 Replies

6. UNIX for Dummies Questions & Answers

Need help with setting up environment variables

hi all, I would appreciate if some one could explain me the difference between setting up the variables as shown below HOME=${HOME:-"/home/user1"} HOME=/home/user1 (1 Reply)
Discussion started by: SSSB
1 Replies

7. UNIX for Dummies Questions & Answers

Setting Environment Variables

#!/bin/bash if ; then ASS1_DATA_DIR=./ echo $ASS1_DATA_DIR export ASS1_DATA_DIR echo "data dir" fi if ; then ASS1_OUTPUT_DIR=./ export ASS1_OUTPUT_DIR fi I want to create a new environment variable ASS1_DATA_DIR and ASS1_OUTPUT_DIR in bash and set them to the current... (4 Replies)
Discussion started by: bigubosu
4 Replies

8. UNIX for Dummies Questions & Answers

Setting up environment variables

Hi all, This is my first post here. I need to set up a few environment variables with a shell script. Some are hard-coded, but some should come from other commands or as input from the user. How do I do that? For example, I need to export a variable as such: export DISPLAY=127.0.0.1:8.0 ... (2 Replies)
Discussion started by: exchequer598
2 Replies

9. Red Hat

Setting up LAMP environment

I wish to setup LAMP environment. Amongst, I have successfully installed Linux 6.1. I am looking fwd to install - Apace Web Server, My Sql Database & PHP environment. Say if I look for MySql, could see downloadable available in rpm format. But this must be copied over to Linux machine. As... (2 Replies)
Discussion started by: videsh77
2 Replies

10. Solaris

/etc/default/init LANG Setting Not Working

Hey guys, I'm setting up a new server(Fujitsu M10-4 / Solaris 10 1/13) to move our app/DB and I'm having trouble figuring out why my LANG setting is not taking effect. I'm trying to set LANG=C in the /etc/default/init file which should make it the default system wide from what I gather. However... (7 Replies)
Discussion started by: kaledragule
7 Replies
setlocale(3)						     Library Functions Manual						      setlocale(3)

NAME
setlocale - Changes or queries the program's current locale LIBRARY
Standard C Library (libc) SYNOPSIS
#include <locale.h> char *setlocale( int category, const char *locale); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: setlocale(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the category of the locale to set or query. The category can be LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, or LC_TIME. Points to a string that specifies the locale. DESCRIPTION
The setlocale() function sets or queries the appropriate portion of the program's locale as specified by the category and locale parame- ters. The LC_ALL value for the category parameter names the entire locale; the other values name only a portion of the program locale, as follows: Affects the behavior of collation functions and regular expressions. Affects the behavior of character classification functions, character conversion functions, and regular expressions. Affects the language used to display application program and utilities messages (when translations of the messages are available) and the strings expected as affirmative and negative responses. Affects the behavior of functions that handle monetary values. Affects the radix character for the formatted input/output functions and the string conversion functions. Affects the behavior of the time conversion functions. The behavior of the language information function defined in the nl_langinfo() function is also affected by settings of the category param- eter. The locale parameter points to a character string that identifies the locale that is to be used to set the category parameter. The locale parameter can specify either the name of a locale, such as fr_CA.ISO8859-1, or one of the following: Sets the locale to be the minimal environment for C-language translation. If setlocale() is not invoked, the C locale is the default. Operational behavior within the C locale is defined separately for each interface function that is affected by the locale string. Equivalent to C. Specifies that the locale should be set based on the user's current values for the locale environment variables. Queries the program's current locale setting and returns the name of the locale; does not change the current setting. If the locale parameter is set to the empty string (""), setlocale() checks the user's environment variables in the following order: First it checks the value of the LC_ALL environment variable. If it is set, setlocale() sets the specified category of the international envi- ronment to that value and returns the string corresponding to the locale set (that is, the value of the environment variable, not "", the null string). If the environment variable LC_ALL is not set or is set to the empty string, setlocale() next checks the corresponding envi- ronment variable for the category specified. If the environment variable for the category is set, setlocale() sets the specified category of the international environment to that value. If the environment variable corresponding to the specified category is not set or is set to the empty string, then setlocale() checks the LANG environment variable. If the LANG environment variable is set, then setlocale() sets the category to the locale specified by the LANG environment variable. Lastly, if the LANG environment variable is not set or is set to the empty string, the setlocale() function sets the category to the POSIX (C) locale. If the locale parameter is a pointer to NULL, the setlocale() function returns the name of the program's current locale for the specified category but does not change the locale. If the locale specified by the locale parameter or by the environment variable is invalid, setlocale() returns a null pointer and does not change the program's locale. EXAMPLES
The following example sets all categories in the international environment based on the user's environment variables: (void)setlocale (LC_ALL, ""); To satisfy this request, the setlocale() function first checks all the environment variables. If any environment variable is invalid, setlocale() returns a null pointer and the international environment is not changed by this function call. If all the rel- evant environment variables are valid, setlocale() sets the international environment to reflect the values of the environment vari- ables. The following example sets a specific category in the international environment to an explicit locale. (void)setlocale(LC_MESSAGES,"fr_FR.ISO8859-1"); The following subroutine queries and saves the current program locale, then explic- itly sets the locale to the C locale, performs some operations in the C locale, and finally, restores the locale to one saved. The main program typically uses setlocale() to set the program's locale to the one specified by the user's environment. However, if a subroutine needs to execute in a specific locale, the subroutine must save and later restore the setting made by the main program. #include <locale.h> #include <string.h> void Do_stuff(void) { char *test_l, *saved_l; test_l=setlocale(LC_ALL,NULL); saved_l=strdup(test_l); test_l=setlocale(LC_ALL,"C"); /* Perform operations in the C locale */ /* Restore the original locale */ test_l=setlocale(LC_ALL,saved_l); return; } NOTES
There is only one locale per process and the locale state is common to all threads within that process. A threaded application should call setlocale() in the main part of the application before any threads are created. If a call to setlocale() changes the setting of the LC_MESSAGES category, this operation has no effect on any message catalogs that are currently open. RETURN VALUES
If the setlocale() function succeeds in setting the program's locale to the one specified by the locale parameter, the function returns the string associated with the specified category parameter for the new locale. Note that the locale parameter can specify the locale name explicitly or, if locale is an empty string, the locale is specified by the value of the corresponding environment variable. If the setlo- cale() function cannot set the program's locale as requested, the function returns a null pointer and leaves the program's locale unchanged. If the category parameter has a value of LC_ALL, the return value is a series of locale names separated by spaces. The locale names corre- spond to the categories in the following order: LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME LC_MESSAGES If the locale parameter is a null pointer, the setlocale() function returns the string associated with the category parameter for the pro- gram's current locale, and leaves the program's locale unchanged. The string returned by the setlocale() function is such that a subsequent call with that string and its associated category restores that part of the program's locale. The string returned must not be modified by the program, but is overwritten by a subsequent call to the set- locale() function. RELATED INFORMATION
Functions: atof(3), catclose(3), catgets(3), catopen(3), ctype(3), localeconv(3), nl_langinfo(3), printf(3), scanf(3), strfmon(3), strf- time(3), string(3), wctype(3), wprintf(3), wscanf(3) Files: locale(4) Others: i18n_intro(5), l10n_intro(5), standards(5) Writing Software for the International Market delim off setlocale(3)
All times are GMT -4. The time now is 03:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy