U E D R , A S I H C RSS

Our Major Lang IsCAndCPlus Plus/locale.h

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.0129 sec