C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- std::locale
- std::use_facet
- std::has_facet
- std::isspace(std::locale)
- std::isblank(std::locale)
- std::codecvt
- std::wstring_convert
- std::iscntrl(std::locale)
- std::isupper(std::locale)
- std::islower(std::locale)
- std::isalpha(std::locale)
- std::isdigit(std::locale)
- std::ispunct(std::locale)
- std::isxdigit(std::locale)
- std::isalnum(std::locale)
- std::isprint(std::locale)
- std::isgraph(std::locale)
- std::toupper(std::locale)
- std::tolower(std::locale)
- std::wbuffer_convert
- std::ctype_base
- std::codecvt_base
- std::messages_base
- std::time_base
- std::money_base
- std::ctype
- std::ctype<char>
- std::collate
- std::messages
- std::time_get
- std::time_put
- std::num_get
- std::num_put
- std::numpunct
- std::money_get
- std::money_put
- std::moneypunct
- std::ctype_byname
- std::codecvt_byname
- std::messages_byname
- std::collate_byname
- std::time_get_byname
- std::time_put_byname
- std::numpunct_byname
- std::moneypunct_byname
- std::codecvt_utf8
- std::codecvt_utf16
- std::codecvt_utf8_utf16
- std::codecvt_mode
- std::setlocale
- std::localeconv
- std::lconv
- LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
- 注é
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >æ¬å°ååº > LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
| å®ä¹äºå¤´æä»¶ <clocale>
|
||
| #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*/ |
||
ä¸é¢æ¯ä¸ªå®å¸¸éé½å±å¼ææ¥æç¸å¼å¼çæ´æ°å¸¸é表达å¼ï¼éåç¨ä½ std::setlocale çé¦ä¸ªåæ°ã
| Â | |
| 常é | è§£é |
LC_ALL
|
éæ©æ´ä¸ª C æ¬å°ç¯å¢ |
LC_COLLATE
|
éæ© C æ¬å°ç¯å¢çå¯¹ç §ç±»å« |
LC_CTYPE
|
éæ© C æ¬å°ç¯å¢ä¸çå符åç±»ç±»å« |
LC_MONETARY
|
éæ© C æ¬å°ç¯å¢ä¸çè´§å¸æ ¼å¼åç±»å« |
LC_NUMERIC
|
éæ© C æ¬å°ç¯å¢ä¸çæ°å¼æ ¼å¼åç±»å« |
LC_TIME
|
éæ© C æ¬å°ç¯å¢ä¸çæ¶é´æ ¼å¼åç±»å« |
<clocale> ä¸å¯ä»¥å®ä¹éå å®å¸¸éï¼å称以 LC_ åéè³å°ä¸ä¸ªå¤§å忝å¼å§ãä¾å¦ï¼ POSIX è§èè¦æ± LC_MESSAGES ï¼æ§å¶ std::perror å std::strerror ï¼ï¼ ISO/IEC 30112:2014 ï¼ 2014 æ¹æ¡ï¼é¢å¤å®ä¹ LC_IDENTIFICATION ã LC_XLITERATE ã LC_NAME ã LC_ADDRESS ã LC_TELEPHONE ã LC_PAPER ã LC_MEASUREMENT å LC_KEYBOARD ï¼å®ä»¬å为 GNU C åºææ¯æï¼é¤äº LC_XLITERATE ï¼ã
示ä¾
è¿è¡æ¤ä»£ç
#include <cstdio> #include <clocale> #include <ctime> #include <cwchar>  int main() { std::setlocale(LC_ALL, "en_US.UTF-8"); // C æ¬å°ç¯å¢å°ä¸ºå¯ç¨ UTF-8 çè±æ std::setlocale(LC_NUMERIC, "de_DE.UTF-8"); // å°æ°ç¹å°ä¸ºå¾·æ std::setlocale(LC_TIME, "ja_JP.UTF-8"); // æ¥æ/æ¶é´æ ¼å¼åå°ä¸ºæ¥æ wchar_t str[100]; std::time_t t = std::time(nullptr); std::wcsftime(str, 100, L"%A %c", std::localtime(&t)); std::wprintf(L"Number: %.2f\nDate: %Ls\n", 3.14, str); }
è¾åºï¼
Number: 3,14 Date: æææ¥ 2011å¹´12æ19æ¥ 18æ04å40ç§
åé
| è·åå设置å½å C æ¬å°ç¯å¢ (彿°) | |
| ç¨ä»¥å°è£
æåå·®å¼ç夿å»é¢çéå (ç±») |