📄 locale2.html
字号:
<HTML><HEAD><TITLE><locale></TITLE></HEAD><BODY><H1><A NAME="<locale>"><CODE><locale></CODE></A></H1><HR><P><B><CODE><A HREF="#codecvt">codecvt</A>· <A HREF="#codecvt_base">codecvt_base</A>· <A HREF="#codecvt_byname">codecvt_byname</A>· <A HREF="#collate">collate</A>· <A HREF="#collate_byname">collate_byname</A>· <A HREF="#ctype">ctype</A>· <A HREF="#ctype<char>">ctype<char></A>· <A HREF="#ctype_base">ctype_base</A>· <A HREF="#ctype_byname">ctype_byname</A>· <A HREF="#has_facet">has_facet</A>· <A HREF="#locale">locale</A>· <A HREF="#messages">messages</A>· <A HREF="#messages_base">messages_base</A>· <A HREF="#messages_byname">messages_byname</A>· <A HREF="#money_base">money_base</A>· <A HREF="#money_get">money_get</A>· <A HREF="#money_put">money_put</A>· <A HREF="#moneypunct">moneypunct</A>· <A HREF="#moneypunct_byname">moneypunct_byname</A>· <A HREF="#num_get">num_get</A>· <A HREF="#num_put">num_put</A>· <A HREF="#numpunct">numpunct</A>· <A HREF="#numpunct_byname">numpunct_byname</A>· <A HREF="#time_base">time_base</A>· <A HREF="#time_get">time_get</A>· <A HREF="#time_get_byname">time_get_byname</A>· <A HREF="#time_put">time_put</A>· <A HREF="#time_put_byname">time_put_byname</A>· <A HREF="#use_facet">use_facet</A></CODE></B></P><P><B><CODE><A HREF="#isalnum">isalnum</A>· <A HREF="#isalpha">isalpha</A>· <A HREF="#iscntrl">iscntrl</A>· <A HREF="#isdigit">isdigit</A>· <A HREF="#isgraph">isgraph</A>· <A HREF="#islower">islower</A>· <A HREF="#isprint">isprint</A>· <A HREF="#ispunct">ispunct</A>· <A HREF="#isspace">isspace</A>· <A HREF="#isupper">isupper</A>· <A HREF="#isxdigit">isxdigit</A>· <A HREF="#tolower">tolower</A>· <A HREF="#toupper">toupper</A></CODE></B></P><HR><P>Include the standard header <B><CODE><locale></CODE></B>to define a host of template classes and functions that encapsulateand manipulate <A HREF="locale.html#locale">locales</A>.</P><PRE>namespace std {class <B><A HREF="#locale">locale</A></B>;class <B><A HREF="#ctype_base">ctype_base</A></B>;template<class Elem> class <B><A HREF="#ctype">ctype</A></B>;template<> class <B><A HREF="#ctype<char>">ctype<char></A></B>;template<class Elem> class <B><A HREF="#ctype_byname">ctype_byname</A></B>;class <B><A HREF="#codecvt_base">codecvt_base</A></B>;template<class Elem, class Byte, class Statype> class <B><A HREF="#codecvt">codecvt</A></B>;template<class Elem, class Byte, class Statype> class <B><A HREF="#codecvt_byname">codecvt_byname</A></B>;template<class Elem, class InIt> class <B><A HREF="#num_get">num_get</A></B>;template<class Elem, class OutIt> class <B><A HREF="#num_put">num_put</A></B>;template<class Elem> class <B><A HREF="#numpunct">numpunct</A></B>;template<class Elem> class <B><A HREF="#numpunct_byname">numpunct_byname</A></B>;template<class Elem> class <B><A HREF="#collate">collate</A></B>;template<class Elem> class <B><A HREF="#collate_byname">collate_byname</A></B>;class <B><A HREF="#time_base">time_base</A></B>;template<class Elem, class InIt> class <B><A HREF="#time_get">time_get</A></B>;template<class Elem, class InIt> class <B><A HREF="#time_get_byname">time_get_byname</A></B>;template<class Elem, class OutIt> class <B><A HREF="#time_put">time_put</A></B>;template<class Elem, class OutIt> class <B><A HREF="#time_put_byname">time_put_byname</A></B>;class <B><A HREF="#money_base">money_base</A></B>;template<class Elem, bool Intl, class InIt> class <B><A HREF="#money_get">money_get</A></B>;template<class Elem, bool Intl, class OutIt> class <B><A HREF="#money_put">money_put</A></B>;template<class Elem, bool Intl> class <B><A HREF="#moneypunct">moneypunct</A></B>;template<class Elem, bool Intl> class <B><A HREF="#moneypunct_byname">moneypunct_byname</A></B>;class <B><A HREF="#messages_base">messages_base</A></B>;template<class Elem> class <B><A HREF="#messages">messages</A></B>;template<class Elem> class <B><A HREF="#messages_byname">messages_byname</A></B>; // TEMPLATE FUNCTIONStemplate<class Facet> bool <B><A HREF="#has_facet">has_facet</A></B>(const locale& loc);template<class Facet> const Facet& <B><A HREF="#use_facet">use_facet</A></B>(const locale& loc);template<class Elem> bool <B><A HREF="#isspace">isspace</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isprint">isprint</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#iscntrl">iscntrl</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isupper">isupper</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#islower">islower</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isalpha">isalpha</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isdigit">isdigit</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#ispunct">ispunct</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isxdigit">isxdigit</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isalnum">isalnum</A></B>(Elem ch, const locale& loc) const;template<class Elem> bool <B><A HREF="#isgraph">isgraph</A></B>(Elem ch, const locale& loc) const;template<class Elem> Elem <B><A HREF="#toupper">toupper</A></B>(Elem ch, const locale& loc) const;template<class Elem> Elem <B><A HREF="#tolower">tolower</A></B>(Elem ch, const locale& loc) const; };</PRE><H2><CODE><A NAME="codecvt">codecvt</A></CODE></H2><PRE>template<class Elem, class Byte, class Statype> class <B>codecvt</B> : public locale::facet, codecvt_base {public: typedef Elem <B><A HREF="#codecvt::intern_type">intern_type</A></B>; typedef Byte <B><A HREF="#codecvt::extern_type">extern_type</A></B>; typedef Statype <B><A HREF="#codecvt::state_type">state_type</A></B>; explicit <B><A HREF="#codecvt::codecvt">codecvt</A></B>(size_t refs = 0); result <B><A HREF="#codecvt::in">in</A></B>(Statype& state, const Byte *first1, const Byte *last1, const Byte *next1, Elem *first2, Elem *last2, Elem *next2); result <B><A HREF="#codecvt::out">out</A></B>(Statype& state, const Elem *first1, const Elem *last1, const Elem *next1, Byte *first2, Byte *last2, Byte *next2); result <B><A HREF="#codecvt::unshift">unshift</A></B>(Statype& state, Byte *first2, Byte *last2, Byte *next2); bool <B><A HREF="#codecvt::always_noconv">always_noconv</A></B>() const throw(); int <B><A HREF="#codecvt::max_length">max_length</A></B>() const throw(); int <B><A HREF="#codecvt::length">length</A></B>(const Statype& state, const Byte *first1, const Byte *last1, size_t _N2) const throw(); int <B><A HREF="#codecvt::encoding">encoding</A></B>() const throw(); static locale::id <B><A HREF="#codecvt::id">id</A></B>;protected: <B>~codecvt</B>(); virtual result <B><A HREF="#codecvt::do_in">do_in</A></B>(Statype& state, const Byte *first1, const Byte *last1, const Byte *next1, Elem *first2, Elem *last2, Elem *next2); virtual result <B><A HREF="#codecvt::do_out">do_out</A></B>(Statype& state, const Elem *first1, const Elem *last1, const Elem *next1, Byte *first2, Byte *last2, Byte *next2); virtual result <B><A HREF="#codecvt::do_unshift">do_unshift</A></B>(Statype& state, Byte *first2, Byte *last2, Byte *next2); virtual bool <B><A HREF="#codecvt::do_always_noconv">do_always_noconv</A></B>() const throw(); virtual int <B><A HREF="#codecvt::do_max_length">do_max_length</A></B>() const throw(); virtual int <B><A HREF="#codecvt::do_encoding">do_encoding</A></B>() const throw(); virtual int <B><A HREF="#codecvt::do_length">do_length</A></B>(const Statype& state, const Byte *first1, const Byte *last1, size_t len2) const throw(); };</PRE><P>The template class describes an object that can serve as a<A HREF="#locale facet">locale facet</A>, to control conversions betweena sequence of values of type <CODE>Elem</CODE>and a sequence of values of type <CODE>Byte</CODE>.The class <CODE>Statype</CODE>characterizes the transformation -- and an object of class<CODE>Statype</CODE> stores any necessary state information duringa conversion.</P><P>As with any locale facet, the static object<B><CODE><A NAME="codecvt::id">id</A></CODE></B> has an initialstored value of zero. The first attempt to access its stored valuestores a unique positive value in <CODE>id</CODE>.</P><P>The template versions of<CODE><A HREF="#codecvt::do_in">do_in</A></CODE> and<CODE><A HREF="#codecvt::do_out">do_out</A></CODE> always return<CODE>codecvt_base::<A HREF="#codecvt_base::noconv">noconv</A></CODE>.The Standard C++ library defines an explicit specialization, however,that is more useful:</P><PRE>template<> codecvt<wchar_t, char, mbstate_t></PRE><P>which converts between <CODE>wchar_t</CODE> and <I>char</I> sequences.</P><H3><CODE><A NAME="codecvt::always_noconv">codecvt::always_noconv</A></CODE></H3><PRE>bool <B>always_noconv</B>() const throw();</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_always_noconv">do_always_noconv</A>()</CODE>.</P><H3><CODE><A NAME="codecvt::codecvt">codecvt::codecvt</A></CODE></H3><PRE>explicit <B>codecvt</B>(size_t refs = 0);</PRE><P>The constructor initializes its<CODE>locale::facet</CODE> base object with<CODE>locale::<A HREF="#locale::facet">facet</A>(refs)</CODE>.</P><H3><CODE><A NAME="codecvt::do_always_noconv">codecvt::do_always_noconv</A></CODE></H3><PRE>virtual bool <B>do_always_noconv</B>() const throw();</PRE><P>The protected virtual member function returns true only if every call to<CODE><A HREF="#codecvt::do_in">do_in</A></CODE> or<CODE><A HREF="#codecvt::do_out">do_out</A></CODE> returns<CODE><A HREF="#codecvt_base::noconv">noconv</A></CODE>.The template version always returns true.</P><H3><CODE><A NAME="codecvt::do_encoding">codecvt::do_encoding</A></CODE></H3><PRE>virtual int <B>do_encoding</B>() const throw();</PRE><P>The protected virtual member function returns:</P><UL><LI>-1, if the encoding of sequences of type <CODE>extern_type</CODE>is state dependent</LI><LI>0, if the encoding involves sequences of varying lengths</LI><LI><CODE>N</CODE>, if the encoding involves only sequences of length<CODE>N</CODE></LI></UL><H3><CODE><A NAME="codecvt::do_in">codecvt::do_in</A></CODE></H3><PRE>virtual result <B>do_in</B>(Statype state&, const Byte *first1, const Byte *last1, const Byte *next1, Elem *first2, Elem *last2, Elem *next2);</PRE><P>The protected virtual member function endeavors to convert thesource sequence at <CODE>[first1, last1)</CODE>to a destination sequence that itstores within <CODE>[first2, last2)</CODE>. It always stores in<CODE>next1</CODE> a pointer to the first unconverted element inthe source sequence, and it always stores in <CODE>next2</CODE> apointer to the first unaltered element in the destination sequence.</P><P><CODE>state</CODE> must represent the<A HREF="charset.html#initial conversion state">initial conversion state</A>at the beginning of a new source sequence. The function alters its storedvalue, as needed, to reflect the current state of asuccessful conversion. Its stored value is otherwise unspecified.</P><P>The function returns:</P><UL><LI><CODE>codecvt_base::<A HREF="#codecvt_base::error">error</A></CODE>if the source sequence is ill formed</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::noconv">noconv</A></CODE>if the function performs no conversion</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::ok">ok</A></CODE>if the conversion succeeds</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::partial">partial</A></CODE>if the source is insufficient, or if the destination is not large enough,for the conversion to succeed</LI></UL><P>The template version always returns <CODE>noconv</CODE>.</P><H3><CODE><A NAME="codecvt::do_length">codecvt::do_length</A></CODE></H3><PRE>virtual int <B>do_length</B>(const Statype state&, const Byte *first1, const Byte *last1, size_t len2) const throw();</PRE><P>The protected virtual member function effectively calls<CODE><A HREF="#codecvt::do_in">do_in</A>(mystate, first1,last1, next1, buf, buf + len2, next2)</CODE>for <CODE>mystate</CODE> a copy of <CODE>state</CODE>,some buffer <CODE>buf</CODE>, and pointers<CODE>next1</CODE> and <CODE>next2</CODE>. Itthen returns <CODE>next2 - buf</CODE>.(Thus, it counts the maximum number of conversions,not greater than <CODE>len2</CODE>, defined by thesource sequence at <CODE>[first1, last1)</CODE>.)</P><P>The template version always returns the lesser of<CODE>last1 - first1</CODE> and <CODE>len2</CODE>.</P><H3><CODE><A NAME="codecvt::do_max_length">codecvt::do_max_length</A></CODE></H3><PRE>virtual int <B>do_max_length</B>() const throw();</PRE><P>The protected virtual member function returnsthe largest permissible value that can be returned by<CODE><A HREF="#codecvt::do_length">do_length</A>(first1,last1, 1)</CODE>, for arbitrary valid values of <CODE>first1</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -