Difference between revisions of "cpp/locale/LC categories"
m (Text replace - "/sidebar" to "/navbar") |
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
||
Line 65: | Line 65: | ||
{{dcl list template | cpp/locale/dcl list locale}} | {{dcl list template | cpp/locale/dcl list locale}} | ||
{{dcl list end}} | {{dcl list end}} | ||
+ | |||
+ | [[de:cpp/locale/LC categories]] | ||
+ | [[es:cpp/locale/LC categories]] | ||
+ | [[fr:cpp/locale/LC categories]] | ||
+ | [[it:cpp/locale/LC categories]] | ||
+ | [[ja:cpp/locale/LC categories]] | ||
+ | [[pt:cpp/locale/LC categories]] | ||
+ | [[ru:cpp/locale/LC categories]] | ||
+ | [[zh:cpp/locale/LC categories]] |
Revision as of 19:56, 2 November 2012
Template:ddcl list begin <tr class="t-dsc-header">
<td><clocale>
<td></td> <td></td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad"><td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad"><td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad"><td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad"><td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad"><td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">
<td class="t-dcl-nopad"><td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end
Each of the above macro constants expand to integer constant expressions with distinct values that are suitable for use as the first argument of std::setlocale.
Constant | Explanation |
LC_ALL
|
selects the entire C locale |
LC_COLLATE
|
selects the collation category of the C locale |
LC_CTYPE
|
selects the character classification category of the C locale |
LC_MONETARY
|
selects the monetary formatting category of the C locale |
LC_NUMERIC
|
selects the numeric formatting category of the C locale |
LC_TIME
|
selects the time formatting category of the C locale |
Additional macro constants, with names that begin with LC_
followed by at least one uppercase letter, may be defined in <clocale>
. For example, the POSIX specification requires LC_MESSAGES and the GNU C library additionally defines LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, and LC_IDENTIFICATION.
Example
#include <cstdio> #include <clocale> #include <ctime> #include <cwchar> int main() { std::setlocale(LC_ALL, "en_US.UTF-8"); // the C locale will be the UTF-8 enabled English std::setlocale(LC_NUMERIC, "de_DE"); // decimal dot will be German std::setlocale(LC_TIME, "ja_JP"); // date/time formatting will be Japanese wchar_t str[100]; std::time_t t = std::time(NULL); std::wcsftime(str, 100, L"%A %c", std::localtime(&t)); std::wprintf(L"Number: %.2f\nDate: %Ls\n", 3.14, str); }
Output:
Number: 3,14 Date: 月曜日 2011年12月19日 18時04分40秒