_create_locale, _wcreate_locale

로캘 개체를 만듭니다.

구문

_locale_t _create_locale(
   int category,
   const char *locale
);
_locale_t _wcreate_locale(
   int category,
   const wchar_t *locale
);

매개 변수

category
범주.

locale
로캘 지정자입니다.

반환 값

유효 locale 하고 category 지정된 경우 함수는 지정된 로캘 설정을 개체로 _locale_t 반환합니다. 프로그램의 현재 로캘 설정은 변경되지 않습니다.

설명

_create_locale 함수를 사용하면 로캘별 버전의 여러 CRT 함수(_l 접미사가 있는 함수)에서 사용하기 위한 특정 지역별 설정을 나타내는 개체를 만들 수 있습니다. 지정된 로캘 설정을 현재 환경에 적용하는 대신, 반환되는 _locale_t 구조체에 설정을 저장한다는 점을 제외하면 동작이 setlocale과 유사합니다. _locale_t 더 이상 필요하지 않은 경우 구조를 사용하여 _free_locale 해제해야 합니다.

_wcreate_locale_create_locale의 와이드 문자 버전이며, locale 에 대한 _wcreate_locale 인수는 와이드 문자열입니다. 그렇지 않으면_wcreate_locale_create_locale 이 동일하게 작동합니다.

category 인수는 영향을 받는 로캘별 동작의 일부를 지정합니다. 사용되는 category 플래그 및 영향을 미치는 프로그램의 부분은 다음 표에 나와 있습니다.

category 플래그 영향
LC_ALL 아래에 나열된 모든 범주입니다.
LC_COLLATE strcoll, _stricoll, wcscoll, _wcsicoll, strxfrm, _strncoll, _strnicoll, _wcsncoll, _wcsnicollwcsxfrm 함수입니다.
LC_CTYPE 문자 처리 함수(영향을 받지 않는 isdigit, isxdigit, mbstowcsmbtowc 제외)입니다.
LC_MONETARY localeconv 함수에 의해 반환되는 통화 서식 정보입니다.
LC_NUMERIC 서식이 지정된 출력 루틴(예: printf), 데이터 변환 루틴 및 localeconv에 의해 반환된 비통화 서식 정보에 대한 소수점 문자입니다. 소수점 문자 LC_NUMERIC 외에도 천 단위 구분 기호와 에서 반환 localeconv하는 그룹화 컨트롤 문자열을 설정합니다.
LC_TIME strftimewcsftime 함수입니다.

이 함수는 categorylocale 매개 변수의 유효성을 검사합니다. 범주 매개 변수가 이전 테이블에 제공된 값 중 하나가 아니거나 있는 경우 locale 함수는 NULL반환합니다 NULL.

locale 인수는 로캘을 지정하는 문자열에 대한 포인터입니다. 인수 형식 locale 에 대한 자세한 내용은 로캘 이름, 언어 및 국가/지역 문자열을 참조 하세요.

인수는 locale 로캘 이름, 언어 문자열, 언어 문자열 및 국가/지역 코드, 코드 페이지 또는 언어 문자열, 국가/지역 코드 및 코드 페이지의 조합과 같은 여러 종류의 값을 사용할 수 있습니다. 사용 가능한 로캘 이름, 언어, 국가/지역 코드 및 코드 페이지 집합에는 Windows NLS API에서 지원하는 모든 항목이 포함됩니다. 지원되는 로캘 이름 _create_locale 집합은 로캘 이름, 언어 및 국가/지역 문자열에 설명되어 있습니다. 지원되는 _create_locale 언어 및 국가/지역 문자열 집합은 언어 문자열 및 국가/지역 문자열나열됩니다.

로캘 설정에 대한 자세한 내용은 다음_wsetlocale을 참조하세요setlocale.

이 함수의 이전 이름인 __create_locale(앞에 밑줄 두 개 포함)은 더 이상 사용되지 않습니다.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

요구 사항

루틴에서 반환된 값 필수 헤더
_create_locale <locale.h>
_wcreate_locale <locale.h> 또는 <wchar.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

// crt_create_locale.c
// Sets the current locale to "de-CH" using the
// setlocale function and demonstrates its effect on the strftime
// function.

#include <stdio.h>
#include <locale.h>
#include <time.h>

int main(void)
{
    time_t ltime;
    struct tm thetime;
    unsigned char str[100];
    _locale_t locale;

    // Create a locale object representing the German (Switzerland) locale
    locale = _create_locale(LC_ALL, "de-CH");
    time (&ltime);
    _gmtime64_s(&thetime, &ltime);

    // %#x is the long date representation, appropriate to
    // the current locale
    if (!_strftime_l((char *)str, 100, "%#x",
                     (const struct tm *)&thetime, locale))
    {
        printf("_strftime_l failed!\n");
    }
    else
    {
        printf("In de-CH locale, _strftime_l returns '%s'\n", str);
    }

    _free_locale(locale);

    // Create a locale object representing the default C locale
    locale = _create_locale(LC_ALL, "C");
    time(&ltime);
    _gmtime64_s(&thetime, &ltime);

    if (!_strftime_l((char *)str, 100, "%#x",
                     (const struct tm *)&thetime, locale))
    {
        printf("_strftime_l failed!\n");
    }
    else
    {
        printf("In 'C' locale, _strftime_l returns '%s'\n", str);
    }

    _free_locale(locale);
}
In de-CH locale, _strftime_l returns 'Samstag, 9. Februar 2002'
In 'C' locale, _strftime_l returns 'Saturday, February 09, 2002'

참고 항목

로캘 이름, 언어 및 국가/지역 문자열
언어 문자열
국가/지역 문자열
_free_locale
_configthreadlocale
setlocale
Locale
localeconv
_mbclen, mblen, _mblen_l
strlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l
mbstowcs, _mbstowcs_l
mbtowc, _mbtowc_l
_setmbcp
setlocale, _wsetlocale
strcoll 함수
strftime, wcsftime, _strftime_l, _wcsftime_l
strxfrm, wcsxfrm, _strxfrm_l, _wcsxfrm_l
wcstombs, _wcstombs_l
wctomb, _wctomb_l