程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> DB2數據庫 >> DB2教程 >> locale::facet::_S_create_c_localenamenotvalid解決方案

locale::facet::_S_create_c_localenamenotvalid解決方案

編輯:DB2教程

locale::facet::_S_create_c_localenamenotvalid解決方案


在很多的shell腳本中,我們經常會看見某一句命令的前面有一句“LC_ALL=C”
SAR_CMD="LC_ALL=C sar -u -b 1 5 | grep -i average "
這到底是什麼意思?
LC_ALL=C 是為了去除所有本地化的設置,讓命令能正確執行。
---------------------------------
在Linux中通過locale來設置程序運行的不同語言環境,locale由ANSI C提供支持。locale的命名規則為<語言>_<地區>.<字符集編碼>,如zh_CN.UTF-8,zh代表中文,CN代表大陸地區,UTF-8表示字符集。在locale環境中,有一組變量,代表國際化環境中的不同設置:1.    LC_COLLATE
定義該環境的排序和比較規則

2.    LC_CTYPE
用於字符分類和字符串處理,控制所有字符的處理方式,包括字符編碼,字符是單字節還是多字節,如何打印等。是最重要的一個環境變量。

3.    LC_MONETARY
貨幣格式

4.    LC_NUMERIC
非貨幣的數字顯示格式

5.    LC_TIME
時間和日期格式

6.    LC_MESSAGES
提示信息的語言。另外還有一個LANGUAGE參數,它與LC_MESSAGES相似,但如果該參數一旦設置,則LC_MESSAGES參數就會失效。LANGUAGE參數可同時設置多種語言信息,如LANGUANE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"。

7.    LANG
LC_*的默認值,是最低級別的設置,如果LC_*沒有設置,則使用該值。類似於 LC_ALL。

8.    LC_ALL
它是一個宏,如果該值設置了,則該值會覆蓋所有LC_*的設置值。注意,LANG的值不受該宏影響。

C"是系統默認的locale,"POSIX"是"C"的別名。所以當我們新安裝完一個系統時,默認的locale就是C或POSIX。

"POSIX" :Specifies the minimal environment for C-language translation called the POSIX locale. If setlocale() is not invoked, the POSIX locale is the default
"C"  Equivalent to "POSIX".
-----------------------------------
How to view the current locale setting?
# locale
How to change the locale setting?
* Via the CDE login locale
* As a user-specific locale
* As a system default locale
To change the current locale setting, first confirm that the desired locale is
installed on the system with:
# locale -a
de
en_AU
en_CA
en_UK
C
If the desired locale is not in the list, you will need to install the
appropriate packages for that locale. See the Note below for more information
about locale packages.

How to change the locale via the CDE login locale?
On the CDE login banner:
Choose options - languages
Under languages - choose the new locale
The CDE banner will re-cycle and then you can login to the selected locale.

NOTE: If a user has a different default locale set in their environment, the
that locale setting will override the selected CDE login locale.

How to set a user-specific locale?
Note:
For sh, ksh:
LANG=C; export LANG
LC_ALL=C; export LC_ALL
For csh:
setenv LANG C
setenv LC_ALL C

Note: To set a default locale for a user's environment, set the LANG or LC_*
variables in a user's shell intialization file such as $HOME/.profile or
$HOME/.cshrc
How to change the locale by setting the system default locale?
LANG=C
LC_ALL=C

Example from the /etc/default/init file:

Lines of this file should be of the form VAR=value, where VAR is one of
TZ, LANG, or any of the LC_* environment variables.
LANG=C
LC_ALL=C

Note: The system must be rebooted after making changes to the
/etc/default/init file in order for the changes to take effect.

How to verify the locale setting?
After setting or changing the locale, verify that the locale is set correctly:
Check if the locale is set correctly by running the locale command without any
options:
# locale
LANG=C
LC_CTYPE= "C"
LC_NUMERIC= "C"
LC_TIME= "C"
LC_COLLATE= "C"
LC_MONETARY= "C"
LC_MESSAGES= "C"
LC_ALL=C

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved