*nix "posix" 中程序的默认语言环境是什么?
Is the default locale of a program in *nix "posix"?
来自The Linux Programming Interface:
There are two different methods of setting the locale using setlocale(). The locale
argument may be a string specifying one of the locales defined on the system (i.e.,
the name of one of the subdirectories under /usr/lib/locale), such as de_DE or en_US.
Alternatively, locale may be specified as an empty string, meaning that locale settings should be taken from environment variables:
setlocale(LC_ALL, "");
我们必须进行此调用,以便程序识别语言环境变量。如果省略调用,这些环境变量对程序没有影响。
所以根据我的理解,如果我的程序没有显式调用 setlocale
函数,我的程序将使用默认的 locale
,即 POSIX
in *nix
系统,对吧?我无法搜索到指定的文档。
正在查看the man
7.4 How Programs Set the Locale
A C program inherits its locale environment variables when it starts up. This happens automatically. However, these variables do not automatically control the locale used by the library functions, because ISO C says that all programs start by default in the standard ‘C’ locale. To use the locales specified by the environment, you must call setlocale. Call it as follows:
setlocale (LC_ALL, "");
强调我的
来自The Linux Programming Interface:
There are two different methods of setting the locale using setlocale(). The locale argument may be a string specifying one of the locales defined on the system (i.e., the name of one of the subdirectories under /usr/lib/locale), such as de_DE or en_US. Alternatively, locale may be specified as an empty string, meaning that locale settings should be taken from environment variables:
setlocale(LC_ALL, "");
我们必须进行此调用,以便程序识别语言环境变量。如果省略调用,这些环境变量对程序没有影响。
所以根据我的理解,如果我的程序没有显式调用 setlocale
函数,我的程序将使用默认的 locale
,即 POSIX
in *nix
系统,对吧?我无法搜索到指定的文档。
正在查看the man
7.4 How Programs Set the Locale
A C program inherits its locale environment variables when it starts up. This happens automatically. However, these variables do not automatically control the locale used by the library functions, because ISO C says that all programs start by default in the standard ‘C’ locale. To use the locales specified by the environment, you must call setlocale. Call it as follows:
setlocale (LC_ALL, "");
强调我的