From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/locale%2Flc_categories.html | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 devdocs/c/locale%2Flc_categories.html (limited to 'devdocs/c/locale%2Flc_categories.html') diff --git a/devdocs/c/locale%2Flc_categories.html b/devdocs/c/locale%2Flc_categories.html new file mode 100644 index 00000000..a4a55fb5 --- /dev/null +++ b/devdocs/c/locale%2Flc_categories.html @@ -0,0 +1,50 @@ +

LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME

Defined in header <locale.h>
#define LC_ALL      /*implementation defined*/
+
#define LC_COLLATE  /*implementation defined*/
+
#define LC_CTYPE    /*implementation defined*/
+
#define LC_MONETARY /*implementation defined*/
+
#define LC_NUMERIC  /*implementation defined*/
+
#define LC_TIME     /*implementation defined*/
+

Each of the above macro constants expand to integer constant expressions with distinct values that are suitable for use as the first argument of 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 locale.h. For example, the POSIX specification requires LC_MESSAGES (which controls, among other things, perror and strerror), ISO/IEC 30112:2014 (2014 draft) additionally defines LC_IDENTIFICATION, LC_XLITERATE, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_PAPER, LC_MEASUREMENT, and LC_KEYBOARD, which are supported by the GNU C library (except for LC_XLITERATE).

+

Example

#include <locale.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+ 
+int main(void)
+{
+    setlocale(LC_ALL, "en_US.UTF-8"); // the C locale will be the UTF-8 enabled English
+    setlocale(LC_NUMERIC, "de_DE.utf8"); // decimal dot will be German
+    setlocale(LC_TIME, "ja_JP.utf8");    // date/time formatting will be Japanese
+    wchar_t str[100];
+    time_t t = time(NULL);
+    wcsftime(str, 100, L"%A %c", localtime(&t));
+    wprintf(L"Number: %.2f\nDate: %Ls\n", 3.14, str);
+}

Possible output:

+
Number: 3,14
+Date: 金曜日 2023年09月15日 20時04分14秒

References

See also

+ +
gets and sets the current C locale
(function)
C++ documentation for locale categories
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/locale/LC_categories +

+
-- cgit v1.2.3