Std::locale
The locale facility includes internationalization support for character classification and string collation, numeric, monetary, and date/time formatting and parsing, and message retrieval. Locale settings control the behavior of stream I/O, regular expression library, and other components of the C++ standard library.
Global setting
#include <locale>
int main(void)
{
std::locale::global(std::locale("ko_KR.UTF-8")); // 맨 처음 한번 실행
return 0;
}
스트림에 적용할 경우 imbue
를 사용하면 된다.
Returns the name of the locale
#include <locale>
#include <iostream>
#include <string>
int main()
{
std::locale loc(std::locale(), new std::ctype<char>);
std::cout << "The default locale is " << std::locale().name() << '\n'
<< "The user's locale is " << std::locale("").name() << '\n'
<< "A nameless locale is " << loc.name() << '\n';
}
See also
Favorite site
- MSDN: International Enabling
- MSDN: Locales and Code Pages
- MSDN: Locale
- cppreference.com: Localization library
- cppreference.com: locale class
- C++ 레퍼런스 - ios_base::imbue
- C++ 레퍼런스 - ios_base::register_callback 함수
- C++ 레퍼런스 - ios_base::getloc 함수
- KLDP: c언어에서 기본적으로 출력되는 한글의 형식은 뭔가요?
- The C Preprocessor: 1.1 Character sets
- [추천] Apache C++ Standard Library User's Guide - 24.3 Differences between the C Locale and the C++ Locales