Clocale
The C language supports localization specific settings, such as culture-specific date formats or country-specific currency symbols.
Category
MBCS vs WCS
이 문서에서는 문자셋 간의 변환에 대해서 살펴보도록 하겠습니다. 문자열 타입 변환 이라하면 단순히 char와 wchar_t간의 변환이라고 생각하기 쉬운데 문자셋이란 개념을 꼭 생각하셔야 합니다.
- MBCS는 한가지 인코딩이 아니다.
- MBCS를 담는 자료형은 char다
- UTF-8도 MBCS와 같은 char에 저장한다.
- Wide Char는 한가지 인코딩 방식이다. (컴파일러에 따라 UTF-16이거나 UTF-32)
- Wide Char는 wchar_t에 담는다.
- 다시 말하면 wchar_t에는 UTF-16이나 UTF-32로 인코딩 된 문자열만 담긴다.
LC Category
=== LANG=C === 결론은 LANG 을 "C" 로 설정하는건 locale 을 끄는 의미이고 "C" 는 표준에 있는 locale name 이 맞다고 한다.
locale name 이 "C" 인것은 C 언어 표준중 7.11.1.1 The setlocale function 에 다음과 같이 지정되어 있기때문이다. (C 언어 표준에 있는 내용이라 "C" 인것 같다)
Simple Example
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(void)
{
/* Locale is set to "C" before this. This call sets it
to the "current locale" by reading environment variables: */
setlocale(LC_ALL, "");
const struct lconv * const currentlocale = localeconv();
printf("In the current locale, the default currency symbol is: %s\n",
currentlocale->currency_symbol);
return EXIT_SUCCESS;
}
See also
Favorite site
- Wikipedia (en) C localization functions
- cppreference.com: Localization support
- cplusplus.com C localization library
- [추천] C/C++: 유니코드(UTF-16) 에서 초성체 판단하기
- 윈도 비주얼 c/c++ 개발자분들이 말하는 '유니코드로 개발하기'란 대체 무엇인가요?
- wchar_t and encoding
- libc 6.1 Introduction to Extended Characters
- Using UTF-8 as the internal representation for strings in C and C++ with Visual Studio 1
- Windows Codepage Interactions with Standard C/C++ filenames?
- UNICODE & MBCS
- 다크 프로그래머: setlocale 사용법
- Locale 설정
- 문자열 타입 변환 관련 C/C++
MSDN
References
-
Using_UTF-8_as_the_internal_representation_for_strings_in_C_and_C++_with_Visual_Studio-Nubaria_Blog.pdf ↩