U E D R , A S I H C RSS

Our Major Lang IsCAndCPlus Plus/locale.h

No older revisions available

No older revisions available



locale.h

담당 : 허준수
location specific information 를 setting 하는데 유용한 라이브러리

매크로

#define LC_ALL (integer constant expression) 모든 카테고리에 대한 로케일 설정을 위한 환경변수이다
#define LC_COLLATE (integer constant expression) 스트링(string)의 정렬 순서(sort order 또는 collation)를 위한 로케일 설정을 위해 사용
#define LC_CTYPE (integer constant expression) 문자 분류(알파벳, 숫자, 한글 또는 소문자, 대문자 등등), 변환, 대소문자 비교을 위한 로케일 설정을 의미
#define LC_MONETARY (integer constant expression) 금액 표현(천단위 구분 문자, 소수점 문자, 금액 표시 문자, 그 위치 등)을 위한 로케일 설정
#define LC_NUMERIC (integer constant expression) 금액이 아닌 숫자 표현(천단위, 소수점, 숫자 그룹핑 등)을 위한 로케일 설정
#define LC_TIME (integer constant expression) 시간과 날짜의 표현(년, 월, 일에 대한 명칭 등)을 위한 로케일 설정 예를 들어 strftime(), strptime()
#define NULL (either 0, 0L, or (void*)0) (0 in C++)

lconv 구조체

struct lconv {
ELEMENT "C" LOCALE LOCALE CATEGORY
char* currency_symbol; "" LC_MONETARY
char* decimal_point; "." LC_NUMERIC
char* grouping; "" LC_NUMERIC
char* int_curr_symbol; "" LC_MONETARY
char* mon_decimal_point; "" LC_MONETARY
char* mon_grouping; "" LC_MONETARY
char* mon_thousands_sep; "" LC_MONETARY
char* negative_sign; "" LC_MONETARY
char* positive_sign; "" LC_MONETARY
char* thousands_sep; "" LC_NUMERIC
char frac_digits; CHAR_MAX LC_MONETARY
char int_frac_digits; CHAR_MAX LC_MONETARY
char n_cs_precedes; CHAR_MAX LC_MONETARY
char n_sep_by_space; CHAR_MAX LC_MONETARY
char n_sign_posn; CHAR_MAX LC_MONETARY
char p_cs_precedes; CHAR_MAX LC_MONETARY
char p_sep_by_space; CHAR_MAX LC_MONETARY
char p_sign_posn; CHAR_MAX LC_MONETARY
};

함수

함수 설명
struct lconv* localeconv(void); lconv 구조체를 현재의 location setting 에 맞게 값을 설정한다.
char* setlocale(int category, const char* locale); category에 대해 로케일 locale을 설정하고 (물론, 사용 가능한 로케일인 경우), 설정된 로케일값을 리턴.

setLocale 의 예

~cpp
  #include <stddef.h>
     #include <locale.h>
     #include <stdlib.h>
     #include <string.h>
     
     void with_other_locale (char *new_locale, void (*subroutine) (int), int argument)
     {
       char *old_locale, *saved_locale;
     
       /* 현재 로케일명을 알아낸다. */
       old_locale = setlocale (LC_ALL, NULL);
     
       /* setlocale()의 재호출 의해 변경될 것을 대비해 로케일 이름을 미리 복사해 둔다. */
       saved_locale = strdup (old_locale);
       if (saved_locale == NULL)
         fatal ("Out of memory");
     
       /* 로케일을 변경하고 subroutine을 수행한다. */
       setlocale (LC_ALL, new_locale);
       (*subroutine) (argument);
     
       /* 원래의 로케일로 복귀한다. */
       setlocale (LC_ALL, saved_locale);
       free (saved_locale);
     }
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:57
Processing time 0.0298 sec