Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME

      From cppreference.com
      <c‎ |locale
       
       
      Localization support
      Locale categories
      LC_ALLLC_COLLATELC_CTYPELC_MONETARYLC_NUMERICLC_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 ofsetlocale.

      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 withLC_ followed by at least one uppercase letter, may be defined inlocale.h. For example, the POSIX specification requiresLC_MESSAGES (which controls, among other things,perror andstrerror), ISO/IEC 30112:2014 (2014 draft) additionally definesLC_IDENTIFICATION,LC_XLITERATE,LC_NAME,LC_ADDRESS,LC_TELEPHONE,LC_PAPER,LC_MEASUREMENT, andLC_KEYBOARD, which are supported by the GNU C library (except forLC_XLITERATE).

      [edit]Example

      Run this code
      #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 Englishsetlocale(LC_NUMERIC,"de_DE.utf8");// decimal dot will be Germansetlocale(LC_TIME,"ja_JP.utf8");// date/time formatting will be Japanesewchar_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,14Date: 金曜日 2023年09月15日 20時04分14秒

      [edit]References

      • C23 standard (ISO/IEC 9899:2024):
      • 7.11/3 Localization <locale.h> (p: TBD)
      • C17 standard (ISO/IEC 9899:2018):
      • 7.11/3 Localization <locale.h> (p: TBD)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.11/3 Localization <locale.h> (p: 224)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.11/3 Localization <locale.h> (p: 205)
      • C89/C90 standard (ISO/IEC 9899:1990):
      • 4.4 LOCALIZATION <locale.h>

      [edit]See also

      gets and sets the current C locale
      (function)[edit]
      C++ documentation forlocale categories
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/locale/LC_categories&oldid=180072"

      [8]ページ先頭

      ©2009-2025 Movatter.jp