📄 locale.html
字号:
<HTML><HEAD><TITLE><locale.h></TITLE></HEAD><BODY><H1><A NAME="<locale.h>"><CODE><locale.h></CODE></A></H1><HR><P>Include the standard header <B><CODE><locale.h></CODE></B>to alter or access properties of the current<B><A NAME="locale">locale</A></B>-- a collection of culture-specific information.An implementation can define additionalmacros in this standard header with names that begin with <CODE>LC_</CODE>.You can use any of these macro names as the<B><A NAME="locale category">locale category</A></B> argument(which selects a cohesive subset of a locale) to<A HREF="#setlocale"><CODE>setlocale</CODE></A>.</P><PRE>#define <A HREF="#LC_ALL"><B>LC_ALL</B></A> <I><integer constant expression></I>#define <A HREF="#LC_COLLATE"><B>LC_COLLATE</B></A> <I><integer constant expression></I>#define <A HREF="#LC_CTYPE"><B>LC_CTYPE</B></A> <I><integer constant expression></I>#define <A HREF="#LC_MONETARY"><B>LC_MONETARY</B></A> <I><integer constant expression></I>#define <A HREF="#LC_NUMERIC"><B>LC_NUMERIC</B></A> <I><integer constant expression></I>#define <A HREF="#LC_TIME"><B>LC_TIME</B></A> <I><integer constant expression></I>#define <A HREF="#NULL"><B>NULL</B></A> <I><either 0, 0L, or (void *)0></I> <B>[0 in C++]</B>struct <A HREF="#lconv"><B>lconv</B></A>;struct lconv *<A HREF="#localeconv"><B>localeconv</B></A>(void);char *<A HREF="#setlocale"><B>setlocale</B></A>(int category, const char *locname);</PRE><H2><A NAME="LC_ALL"><CODE>LC_ALL</CODE></A></H2><PRE>#define <B>LC_ALL</B> <I><integer constant expression></I></PRE><P>The macro yields the<A HREF="#locale category">locale category</A>argument value that affects all locale categories.</P><H2><A NAME="LC_COLLATE"><CODE>LC_COLLATE</CODE></A></H2><PRE>#define <B>LC_COLLATE</B> <I><integer constant expression></I></PRE><P>The macro yields the<A HREF="#locale category">locale category</A>argument value that affects the collation functions<CODE>strcoll</CODE> and<CODE>strxfrm</CODE>.</P><H2><A NAME="LC_CTYPE"><CODE>LC_CTYPE</CODE></A></H2><PRE>#define <B>LC_CTYPE</B> <I><integer constant expression></I></PRE><P>The macro yields the<A HREF="#locale category">locale category</A>argument value that affects<A HREF="ctype.html">character classification</A> functions,<A HREF="wctype.html">wide-character classification</A> functions,and various multibyte conversion functions.</P><H2><A NAME="LC_MONETARY"><CODE>LC_MONETARY</CODE></A></H2><PRE>#define <B>LC_MONETARY</B> <I><integer constant expression></I></PRE><P>The macro yields the<A HREF="#locale category">locale category</A>argument value that affects monetary information returned by<A HREF="#localeconv"><CODE>localeconv</CODE></A>.</P><H2><A NAME="LC_NUMERIC"><CODE>LC_NUMERIC</CODE></A></H2><PRE>#define <B>LC_NUMERIC</B> <I><integer constant expression></I></PRE><P>The macro yields the<A HREF="#locale category">locale category</A>argument value that affects numeric information returned by<A HREF="#localeconv"><CODE>localeconv</CODE></A>,including the decimal point used by numeric conversion,read, and write functions.</P><H2><A NAME="LC_TIME"><CODE>LC_TIME</CODE></A></H2><PRE>#define <B>LC_TIME</B> <I><integer constant expression></I></PRE><P>The macro yields the<A HREF="#locale category">locale category</A>argument value that affects the time conversion function<A HREF="time.html#strftime"><CODE>strftime</CODE></A>.</P><H2><A NAME="lconv"><CODE>lconv</CODE></A></H2><PRE>struct <B>lconv</B> { <B>ELEMENT</B> <B>"C" LOCALE</B> <B>LOCALE CATEGORY</B> char *decimal_point; <B>"."</B> <B>LC_NUMERIC</B> char *grouping; <B>""</B> <B>LC_NUMERIC</B> char *thousands_sep; <B>""</B> <B>LC_NUMERIC</B> char *mon_decimal_point; <B>""</B> <B>LC_MONETARY</B> char *mon_grouping; <B>""</B> <B>LC_MONETARY</B> char *mon_thousands_sep; <B>""</B> <B>LC_MONETARY</B> char *negative_sign; <B>""</B> <B>LC_MONETARY</B> char *positive_sign; <B>""</B> <B>LC_MONETARY</B> char *currency_symbol; <B>""</B> <B>LC_MONETARY</B> char frac_digits; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char n_cs_precedes; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char n_sep_by_space; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char n_sign_posn; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char p_cs_precedes; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char p_sep_by_space; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char p_sign_posn; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char *int_curr_symbol; <B>""</B> <B>LC_MONETARY</B> char int_frac_digits; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char int_n_cs_precedes; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char int_n_sep_by_space; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char int_n_sign_posn; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char int_p_cs_precedes; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char int_p_sep_by_space; <B>CHAR_MAX</B> <B>LC_MONETARY</B> char int_p_sign_posn; <B>CHAR_MAX</B> <B>LC_MONETARY</B> };</PRE><P><CODE>struct lconv</CODE> contains members that describe how to formatnumeric and monetary values. Functions in the Standard C library useonly the field <CODE>decimal_point</CODE>.The information is otherwise advisory:</P><UL><LI>Members of type <I>pointer to char</I> all designate<A HREF="lib_over.html#C string">C strings</A>.<LI>Members of type <I>char</I> have nonnegative values.<LI>A <I>char</I> value of<A HREF="limits.html#CHAR_MAX"><CODE>CHAR_MAX</CODE></A>indicates that a meaningfulvalue is not available in the current locale.</UL><P>The members shown above can occur in arbitrary order and canbe interspersed with additional members. The comment following eachmember shows its value for the<B><A NAME="C locale"><CODE>"C"</CODE> locale</A></B>,the locale in effect at<A HREF="lib_over.html#program startup">program startup</A>,followed by the<A HREF="#locale category">locale category</A>that can affect its value.</P><P>A description of each member follows, with an example in parenthesesthat would be suitable for a USA locale.</P><P><B><A NAME="currency_symbol"><CODE>currency_symbol</CODE></A></B>-- the local currency symbol (<CODE>"$"</CODE>)</P><P><B><A NAME="decimal_point"><CODE>decimal_point</CODE></A></B>-- the decimal point for non-monetary values (<CODE>"."</CODE>)</P><P><B><A NAME="grouping"><CODE>grouping</CODE></A></B>-- the sizes of digit groups for non-monetary values.Successive elements of the string describe groups going awayfrom the decimal point:</P><UL><LI>An element value of zero (the terminating null character) callsfor the previous element value to be repeated indefinitely.<LI>An element value of<A HREF="limits.html#CHAR_MAX"><CODE>CHAR_MAX</CODE></A>ends any further grouping (and hence ends the string).</UL><P>Thus, the array <CODE>{3, 2, CHAR_MAX}</CODE> calls for a group ofthree digits, then two, then whatever remains, as in<CODE>9876,54,321</CODE>, while <CODE>"\3"</CODE>calls for repeated groups of three digits, as in<CODE>987,654,321</CODE>. (<CODE>"\3"</CODE>)</P><P><B><A NAME="int_curr_symbol"><CODE>int_curr_symbol</CODE></A></B>-- the international currency symbolspecified by ISO 4217 (<CODE>"USD "</CODE>)</P><P><B><A NAME="mon_decimal_point"><CODE>mon_decimal_point</CODE></A></B>-- the decimal point for monetary values (<CODE>"."</CODE>)</P><P><B><A NAME="mon_grouping"><CODE>mon_grouping</CODE></A></B>-- the sizes of digit groups for monetary values.Successive elements of the string describe groups going awayfrom the decimal point. The encoding is the same as for<A HREF="#grouping"><CODE>grouping</CODE></A>.</P><P><B><A NAME="mon_thousands_sep"><CODE>mon_thousands_sep</CODE></A></B>-- the separator for digit groups to the left of the decimal pointfor monetary values (<CODE>","</CODE>)</P><P><B><A NAME="negative_sign"><CODE>negative_sign</CODE></A></B>-- the negative sign for monetary values (<CODE>"-"</CODE>)</P><P><B><A NAME="positive_sign"><CODE>positive_sign</CODE></A></B>-- the positive sign for monetary values (<CODE>"+"</CODE>)</P><P><B><A NAME="thousands_sep"><CODE>thousands_sep</CODE></A></B>-- the separator for digit groups to the left of the decimal pointfor non-monetary values (<CODE>","</CODE>)</P><P><B><A NAME="frac_digits"><CODE>frac_digits</CODE></A></B>-- the number of digits to display to the right of the decimal pointfor monetary values (<CODE>2</CODE>)</P><P><B><A NAME="int_frac_digits"><CODE>int_frac_digits</CODE></A></B>-- the number of digits to display to the right of the decimal pointfor international monetary values (<CODE>2</CODE>)</P><P><B><A NAME="int_n_cs_precedes"><CODE>int_n_cs_precedes</CODE></A></B>-- whether the international currency symbolprecedes or follows the value for negative monetary values:</P><UL><LI>A value of 0 indicates that the symbol follows the value.<LI>A value of 1 indicates that the symbol precedes the value.(<CODE>1</CODE>)</UL><P><B><A NAME="int_n_sep_by_space"><CODE>int_n_sep_by_space</CODE></A></B>-- whether the international currency symbol
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -