tmp/tmp9jkdbcy9/{from.md → to.md}
RENAMED
|
@@ -41,10 +41,11 @@ namespace std {
|
|
| 41 |
template <class charT> bool isdigit (charT c, const locale& loc);
|
| 42 |
template <class charT> bool ispunct (charT c, const locale& loc);
|
| 43 |
template <class charT> bool isxdigit(charT c, const locale& loc);
|
| 44 |
template <class charT> bool isalnum (charT c, const locale& loc);
|
| 45 |
template <class charT> bool isgraph (charT c, const locale& loc);
|
|
|
|
| 46 |
template <class charT> charT toupper(charT c, const locale& loc);
|
| 47 |
template <class charT> charT tolower(charT c, const locale& loc);
|
| 48 |
template <class Codecvt, class Elem = wchar_t,
|
| 49 |
class Wide_alloc = std::allocator<Elem>,
|
| 50 |
class Byte_alloc = std::allocator<char> > class wstring_convert;
|
|
@@ -72,21 +73,21 @@ namespace std {
|
|
| 72 |
|
| 73 |
// [category.time], date and time:
|
| 74 |
class time_base;
|
| 75 |
template <class charT, class InputIterator = istreambuf_iterator<charT> >
|
| 76 |
class time_get;
|
| 77 |
-
template <class charT, class InputIterator
|
| 78 |
class time_get_byname;
|
| 79 |
-
template <class charT, class OutputIterator
|
| 80 |
class time_put;
|
| 81 |
-
template <class charT, class OutputIterator
|
| 82 |
class time_put_byname;
|
| 83 |
|
| 84 |
// [category.monetary], money:
|
| 85 |
class money_base;
|
| 86 |
-
template <class charT, class InputIterator = istreambuf_iterator<charT> >
|
| 87 |
-
template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
|
| 88 |
template <class charT, bool Intl = false> class moneypunct;
|
| 89 |
template <class charT, bool Intl = false> class moneypunct_byname;
|
| 90 |
|
| 91 |
// [category.messages], message retrieval:
|
| 92 |
class messages_base;
|
|
@@ -309,20 +310,20 @@ The provided implementation of members of facets `num_get<charT>` and
|
|
| 309 |
`num_put<charT>` calls `use_facet <F> (l)` only for facet `F` of types
|
| 310 |
`numpunct<charT>` and `ctype<charT>`, and for locale `l` the value
|
| 311 |
obtained by calling member `getloc()` on the `ios_base&` argument to
|
| 312 |
these functions.
|
| 313 |
|
| 314 |
-
In declarations of facets, a template
|
| 315 |
`InputIterator` or `OutputIterator` indicates the set of all possible
|
| 316 |
specializations on parameters that satisfy the requirements of an Input
|
| 317 |
Iterator or an Output Iterator, respectively (
|
| 318 |
-
[[iterator.requirements]]). A template
|
| 319 |
represents the set of types containing `char`, `wchar_t`, and any other
|
| 320 |
implementation-defined character types that satisfy the requirements for
|
| 321 |
a character on which any of the iostream components can be instantiated.
|
| 322 |
-
A template
|
| 323 |
-
|
| 324 |
|
| 325 |
##### Class `locale::facet` <a id="locale.facet">[[locale.facet]]</a>
|
| 326 |
|
| 327 |
``` cpp
|
| 328 |
namespace std {
|
|
@@ -412,14 +413,10 @@ value for arguments of functions that take a `const locale&` argument.
|
|
| 412 |
locale(const locale& other) noexcept;
|
| 413 |
```
|
| 414 |
|
| 415 |
*Effects:* Constructs a locale which is a copy of `other`.
|
| 416 |
|
| 417 |
-
*Effects:* Creates a copy of `other`, replacing the current value.
|
| 418 |
-
|
| 419 |
-
*Returns:* `*this`
|
| 420 |
-
|
| 421 |
``` cpp
|
| 422 |
explicit locale(const char* std_name);
|
| 423 |
```
|
| 424 |
|
| 425 |
*Effects:* Constructs a locale using standard C locale names, e.g.,
|
|
@@ -479,10 +476,14 @@ arguments have names.
|
|
| 479 |
|
| 480 |
``` cpp
|
| 481 |
const locale& operator=(const locale& other) noexcept;
|
| 482 |
```
|
| 483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
``` cpp
|
| 485 |
~locale();
|
| 486 |
```
|
| 487 |
|
| 488 |
A non-virtual destructor that throws no exceptions.
|
|
@@ -660,18 +661,17 @@ template <class charT> charT tolower(charT c, const locale& loc);
|
|
| 660 |
##### `string` conversions <a id="conversions.string">[[conversions.string]]</a>
|
| 661 |
|
| 662 |
Class template `wstring_convert` performs conversions between a wide
|
| 663 |
string and a byte string. It lets you specify a code conversion facet
|
| 664 |
(like class template `codecvt`) to perform the conversions, without
|
| 665 |
-
affecting any streams or locales.
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
like:
|
| 670 |
|
| 671 |
``` cpp
|
| 672 |
-
wstring_convert<codecvt_utf8<wchar_t>> myconv;
|
| 673 |
std::string mbstring = myconv.to_bytes(L"Hello\n");
|
| 674 |
std::cout << mbstring;
|
| 675 |
```
|
| 676 |
|
| 677 |
``` cpp
|
|
@@ -683,27 +683,30 @@ template<class Codecvt, class Elem = wchar_t,
|
|
| 683 |
typedef std::basic_string<char, char_traits<char>, Byte_alloc> byte_string;
|
| 684 |
typedef std::basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
|
| 685 |
typedef typename Codecvt::state_type state_type;
|
| 686 |
typedef typename wide_string::traits_type::int_type int_type;
|
| 687 |
|
| 688 |
-
wstring_convert(Codecvt
|
| 689 |
wstring_convert(Codecvt* pcvt, state_type state);
|
| 690 |
-
wstring_convert(const byte_string& byte_err,
|
| 691 |
const wide_string& wide_err = wide_string());
|
| 692 |
~wstring_convert();
|
| 693 |
|
|
|
|
|
|
|
|
|
|
| 694 |
wide_string from_bytes(char byte);
|
| 695 |
wide_string from_bytes(const char* ptr);
|
| 696 |
wide_string from_bytes(const byte_string& str);
|
| 697 |
wide_string from_bytes(const char* first, const char* last);
|
| 698 |
|
| 699 |
byte_string to_bytes(Elem wchar);
|
| 700 |
byte_string to_bytes(const Elem* wptr);
|
| 701 |
byte_string to_bytes(const wide_string& wstr);
|
| 702 |
byte_string to_bytes(const Elem* first, const Elem* last);
|
| 703 |
|
| 704 |
-
size_t converted() const;
|
| 705 |
state_type state() const;
|
| 706 |
private:
|
| 707 |
byte_string byte_err_string; // exposition only
|
| 708 |
wide_string wide_err_string; // exposition only
|
| 709 |
Codecvt* cvtptr; // exposition only
|
|
@@ -716,15 +719,14 @@ template<class Codecvt, class Elem = wchar_t,
|
|
| 716 |
The class template describes an object that controls conversions between
|
| 717 |
wide string objects of class `std::basic_string<Elem, char_traits<Elem>,
|
| 718 |
Wide_alloc>` and byte string objects of class `std::\\basic_string<char,
|
| 719 |
char_traits<char>, Byte_alloc>`. The class template defines the types
|
| 720 |
`wide_string` and `byte_string` as synonyms for these two types.
|
| 721 |
-
Conversion between a sequence of `Elem` values (stored in a
|
| 722 |
-
object) and multibyte sequences (stored in a byte_string
|
| 723 |
-
performed by an object of class `Codecvt
|
| 724 |
-
|
| 725 |
-
`std::codecvt<Elem,
|
| 726 |
char, std::mbstate_t>`.
|
| 727 |
|
| 728 |
An object of this class template stores:
|
| 729 |
|
| 730 |
- `byte_err_string` — a byte string to display on errors
|
|
@@ -733,17 +735,18 @@ An object of this class template stores:
|
|
| 733 |
freed when the `wstring_convert` object is destroyed)
|
| 734 |
- `cvtstate` — a conversion state object
|
| 735 |
- `cvtcount` — a conversion count
|
| 736 |
|
| 737 |
``` cpp
|
| 738 |
-
typedef std::basic_string<char> byte_string;
|
| 739 |
```
|
| 740 |
|
| 741 |
-
The type shall be a synonym for
|
|
|
|
| 742 |
|
| 743 |
``` cpp
|
| 744 |
-
size_t converted() const;
|
| 745 |
```
|
| 746 |
|
| 747 |
*Returns:* `cvtcount`.
|
| 748 |
|
| 749 |
``` cpp
|
|
@@ -819,22 +822,25 @@ return the converted byte string. Otherwise, if the object was
|
|
| 819 |
constructed with a byte-error string, the member function shall return
|
| 820 |
the byte-error string. Otherwise, the member function shall throw an
|
| 821 |
object of class `std::range_error`.
|
| 822 |
|
| 823 |
``` cpp
|
| 824 |
-
typedef std::basic_string<Elem> wide_string;
|
| 825 |
```
|
| 826 |
|
| 827 |
-
The type shall be a synonym for
|
|
|
|
| 828 |
|
| 829 |
``` cpp
|
| 830 |
-
wstring_convert(Codecvt
|
| 831 |
wstring_convert(Codecvt* pcvt, state_type state);
|
| 832 |
-
wstring_convert(const byte_string& byte_err,
|
| 833 |
const wide_string& wide_err = wide_string());
|
| 834 |
```
|
| 835 |
|
|
|
|
|
|
|
| 836 |
*Effects:* The first constructor shall store `pcvt` in `cvtptr` and
|
| 837 |
default values in `cvtstate`, `byte_err_string`, and `wide_err_string`.
|
| 838 |
The second constructor shall store `pcvt` in `cvtptr`, `state` in
|
| 839 |
`cvtstate`, and default values in `byte_err_string` and
|
| 840 |
`wide_err_string`; moreover the stored state shall be retained between
|
|
@@ -864,14 +870,19 @@ template<class Codecvt,
|
|
| 864 |
class wbuffer_convert
|
| 865 |
: public std::basic_streambuf<Elem, Tr> {
|
| 866 |
public:
|
| 867 |
typedef typename Codecvt::state_type state_type;
|
| 868 |
|
| 869 |
-
wbuffer_convert(std::streambuf
|
| 870 |
Codecvt* pcvt = new Codecvt,
|
| 871 |
state_type state = state_type());
|
| 872 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 873 |
std::streambuf* rdbuf() const;
|
| 874 |
std::streambuf* rdbuf(std::streambuf* bytebuf);
|
| 875 |
|
| 876 |
state_type state() const;
|
| 877 |
|
|
@@ -885,13 +896,12 @@ template<class Codecvt,
|
|
| 885 |
|
| 886 |
The class template describes a stream buffer that controls the
|
| 887 |
transmission of elements of type `Elem`, whose character traits are
|
| 888 |
described by the class `Tr`, to and from a byte stream buffer of type
|
| 889 |
`std::streambuf`. Conversion between a sequence of `Elem` values and
|
| 890 |
-
multibyte sequences is performed by an object of class
|
| 891 |
-
|
| 892 |
-
of the standard code-conversion facet
|
| 893 |
`std::codecvt<Elem, char, std::mbstate_t>`.
|
| 894 |
|
| 895 |
An object of this class template stores:
|
| 896 |
|
| 897 |
- `bufptr` — a pointer to its underlying byte stream buffer
|
|
@@ -924,14 +934,16 @@ typedef typename Codecvt::state_type state_type;
|
|
| 924 |
```
|
| 925 |
|
| 926 |
The type shall be a synonym for `Codecvt::state_type`.
|
| 927 |
|
| 928 |
``` cpp
|
| 929 |
-
wbuffer_convert(std::streambuf
|
| 930 |
Codecvt* pcvt = new Codecvt, state_type state = state_type());
|
| 931 |
```
|
| 932 |
|
|
|
|
|
|
|
| 933 |
*Effects:* The constructor constructs a stream buffer object,
|
| 934 |
initializes `bufptr` to `bytebuf`, initializes `cvtptr` to `pcvt`, and
|
| 935 |
initializes `cvtstate` to `state`.
|
| 936 |
|
| 937 |
``` cpp
|
|
@@ -1495,19 +1507,20 @@ mapped between.
|
|
| 1495 |
The specializations required in Table
|
| 1496 |
[[tab:localization.category.facets]] ([[locale.category]]) convert the
|
| 1497 |
implementation-defined native character set.
|
| 1498 |
`codecvt<char, char, mbstate_t>` implements a degenerate conversion; it
|
| 1499 |
does not convert at all. The specialization `codecvt<char16_t,`
|
| 1500 |
-
`char, mbstate_t>` converts between the UTF-16 and UTF-8 encoding
|
| 1501 |
-
|
| 1502 |
-
|
| 1503 |
`codecvt<wchar_t,char,mbstate_t>` converts between the native character
|
| 1504 |
sets for narrow and wide characters. Specializations on `mbstate_t`
|
| 1505 |
perform conversion between encodings known to the library implementer.
|
| 1506 |
Other encodings can be converted by specializing on a user-defined
|
| 1507 |
-
`stateT` type.
|
| 1508 |
-
to communicate to or from the specialized `do_in` or `do_out`
|
|
|
|
| 1509 |
|
| 1510 |
##### `codecvt` members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
|
| 1511 |
|
| 1512 |
``` cpp
|
| 1513 |
result out(stateT& state,
|
|
@@ -2321,12 +2334,12 @@ iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
|
| 2321 |
`do_put(out, str, fill,`
|
| 2322 |
`(int)val)`, otherwise obtains a string `s` as if by
|
| 2323 |
|
| 2324 |
``` cpp
|
| 2325 |
string_type s =
|
| 2326 |
-
val ? use_facet<
|
| 2327 |
-
: use_facet<
|
| 2328 |
```
|
| 2329 |
|
| 2330 |
and then inserts each character `c` of `s` into `out` via `*out++ = c`
|
| 2331 |
and returns `out`.
|
| 2332 |
|
|
@@ -2854,11 +2867,11 @@ recognized as part of a valid year identifier.
|
|
| 2854 |
``` cpp
|
| 2855 |
iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
| 2856 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 2857 |
```
|
| 2858 |
|
| 2859 |
-
*Requires:* `t` shall
|
| 2860 |
|
| 2861 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 2862 |
It then reads characters starting at `s` until it encounters an error,
|
| 2863 |
or until it has extracted and assigned those `struct tm` members, and
|
| 2864 |
any remaining format characters, corresponding to a conversion directive
|
|
@@ -3437,11 +3450,11 @@ catalogs.
|
|
| 3437 |
|
| 3438 |
``` cpp
|
| 3439 |
namespace std {
|
| 3440 |
class messages_base {
|
| 3441 |
public:
|
| 3442 |
-
typedef
|
| 3443 |
};
|
| 3444 |
|
| 3445 |
template <class charT>
|
| 3446 |
class messages : public locale::facet, public messages_base {
|
| 3447 |
public:
|
|
@@ -3738,25 +3751,31 @@ namespace std {
|
|
| 3738 |
|
| 3739 |
template<class Elem, unsigned long Maxcode = 0x10ffff,
|
| 3740 |
codecvt_mode Mode = (codecvt_mode)0>
|
| 3741 |
class codecvt_utf8
|
| 3742 |
: public codecvt<Elem, char, mbstate_t> {
|
| 3743 |
-
|
|
|
|
|
|
|
| 3744 |
};
|
| 3745 |
|
| 3746 |
template<class Elem, unsigned long Maxcode = 0x10ffff,
|
| 3747 |
codecvt_mode Mode = (codecvt_mode)0>
|
| 3748 |
class codecvt_utf16
|
| 3749 |
: public codecvt<Elem, char, mbstate_t> {
|
| 3750 |
-
|
|
|
|
|
|
|
| 3751 |
};
|
| 3752 |
|
| 3753 |
template<class Elem, unsigned long Maxcode = 0x10ffff,
|
| 3754 |
codecvt_mode Mode = (codecvt_mode)0>
|
| 3755 |
class codecvt_utf8_utf16
|
| 3756 |
: public codecvt<Elem, char, mbstate_t> {
|
| 3757 |
-
|
|
|
|
|
|
|
| 3758 |
};
|
| 3759 |
}
|
| 3760 |
```
|
| 3761 |
|
| 3762 |
For each of the three code conversion facets `codecvt_utf8`,
|
|
|
|
| 41 |
template <class charT> bool isdigit (charT c, const locale& loc);
|
| 42 |
template <class charT> bool ispunct (charT c, const locale& loc);
|
| 43 |
template <class charT> bool isxdigit(charT c, const locale& loc);
|
| 44 |
template <class charT> bool isalnum (charT c, const locale& loc);
|
| 45 |
template <class charT> bool isgraph (charT c, const locale& loc);
|
| 46 |
+
template <class charT> bool isblank (charT c, const locale& loc);
|
| 47 |
template <class charT> charT toupper(charT c, const locale& loc);
|
| 48 |
template <class charT> charT tolower(charT c, const locale& loc);
|
| 49 |
template <class Codecvt, class Elem = wchar_t,
|
| 50 |
class Wide_alloc = std::allocator<Elem>,
|
| 51 |
class Byte_alloc = std::allocator<char> > class wstring_convert;
|
|
|
|
| 73 |
|
| 74 |
// [category.time], date and time:
|
| 75 |
class time_base;
|
| 76 |
template <class charT, class InputIterator = istreambuf_iterator<charT> >
|
| 77 |
class time_get;
|
| 78 |
+
template <class charT, class InputIterator = istreambuf_iterator<charT> >
|
| 79 |
class time_get_byname;
|
| 80 |
+
template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
|
| 81 |
class time_put;
|
| 82 |
+
template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
|
| 83 |
class time_put_byname;
|
| 84 |
|
| 85 |
// [category.monetary], money:
|
| 86 |
class money_base;
|
| 87 |
+
template <class charT, class InputIterator = istreambuf_iterator<charT> > class money_get;
|
| 88 |
+
template <class charT, class OutputIterator = ostreambuf_iterator<charT> > class money_put;
|
| 89 |
template <class charT, bool Intl = false> class moneypunct;
|
| 90 |
template <class charT, bool Intl = false> class moneypunct_byname;
|
| 91 |
|
| 92 |
// [category.messages], message retrieval:
|
| 93 |
class messages_base;
|
|
|
|
| 310 |
`num_put<charT>` calls `use_facet <F> (l)` only for facet `F` of types
|
| 311 |
`numpunct<charT>` and `ctype<charT>`, and for locale `l` the value
|
| 312 |
obtained by calling member `getloc()` on the `ios_base&` argument to
|
| 313 |
these functions.
|
| 314 |
|
| 315 |
+
In declarations of facets, a template parameter with name
|
| 316 |
`InputIterator` or `OutputIterator` indicates the set of all possible
|
| 317 |
specializations on parameters that satisfy the requirements of an Input
|
| 318 |
Iterator or an Output Iterator, respectively (
|
| 319 |
+
[[iterator.requirements]]). A template parameter with name `C`
|
| 320 |
represents the set of types containing `char`, `wchar_t`, and any other
|
| 321 |
implementation-defined character types that satisfy the requirements for
|
| 322 |
a character on which any of the iostream components can be instantiated.
|
| 323 |
+
A template parameter with name `International` represents the set of all
|
| 324 |
+
possible specializations on a bool parameter.
|
| 325 |
|
| 326 |
##### Class `locale::facet` <a id="locale.facet">[[locale.facet]]</a>
|
| 327 |
|
| 328 |
``` cpp
|
| 329 |
namespace std {
|
|
|
|
| 413 |
locale(const locale& other) noexcept;
|
| 414 |
```
|
| 415 |
|
| 416 |
*Effects:* Constructs a locale which is a copy of `other`.
|
| 417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
``` cpp
|
| 419 |
explicit locale(const char* std_name);
|
| 420 |
```
|
| 421 |
|
| 422 |
*Effects:* Constructs a locale using standard C locale names, e.g.,
|
|
|
|
| 476 |
|
| 477 |
``` cpp
|
| 478 |
const locale& operator=(const locale& other) noexcept;
|
| 479 |
```
|
| 480 |
|
| 481 |
+
*Effects:* Creates a copy of `other`, replacing the current value.
|
| 482 |
+
|
| 483 |
+
*Returns:* `*this`
|
| 484 |
+
|
| 485 |
``` cpp
|
| 486 |
~locale();
|
| 487 |
```
|
| 488 |
|
| 489 |
A non-virtual destructor that throws no exceptions.
|
|
|
|
| 661 |
##### `string` conversions <a id="conversions.string">[[conversions.string]]</a>
|
| 662 |
|
| 663 |
Class template `wstring_convert` performs conversions between a wide
|
| 664 |
string and a byte string. It lets you specify a code conversion facet
|
| 665 |
(like class template `codecvt`) to perform the conversions, without
|
| 666 |
+
affecting any streams or locales. If you want to use the code conversion
|
| 667 |
+
facet `codecvt_utf8` to output to `cout` a UTF-8 multibyte sequence
|
| 668 |
+
corresponding to a wide string, but you don’t want to alter the locale
|
| 669 |
+
for `cout`, you can write something like:
|
|
|
|
| 670 |
|
| 671 |
``` cpp
|
| 672 |
+
wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
|
| 673 |
std::string mbstring = myconv.to_bytes(L"Hello\n");
|
| 674 |
std::cout << mbstring;
|
| 675 |
```
|
| 676 |
|
| 677 |
``` cpp
|
|
|
|
| 683 |
typedef std::basic_string<char, char_traits<char>, Byte_alloc> byte_string;
|
| 684 |
typedef std::basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
|
| 685 |
typedef typename Codecvt::state_type state_type;
|
| 686 |
typedef typename wide_string::traits_type::int_type int_type;
|
| 687 |
|
| 688 |
+
explicit wstring_convert(Codecvt* pcvt = new Codecvt);
|
| 689 |
wstring_convert(Codecvt* pcvt, state_type state);
|
| 690 |
+
explicit wstring_convert(const byte_string& byte_err,
|
| 691 |
const wide_string& wide_err = wide_string());
|
| 692 |
~wstring_convert();
|
| 693 |
|
| 694 |
+
wstring_convert(const wstring_convert&) = delete;
|
| 695 |
+
wstring_convert& operator=(const wstring_convert&) = delete;
|
| 696 |
+
|
| 697 |
wide_string from_bytes(char byte);
|
| 698 |
wide_string from_bytes(const char* ptr);
|
| 699 |
wide_string from_bytes(const byte_string& str);
|
| 700 |
wide_string from_bytes(const char* first, const char* last);
|
| 701 |
|
| 702 |
byte_string to_bytes(Elem wchar);
|
| 703 |
byte_string to_bytes(const Elem* wptr);
|
| 704 |
byte_string to_bytes(const wide_string& wstr);
|
| 705 |
byte_string to_bytes(const Elem* first, const Elem* last);
|
| 706 |
|
| 707 |
+
size_t converted() const noexcept;
|
| 708 |
state_type state() const;
|
| 709 |
private:
|
| 710 |
byte_string byte_err_string; // exposition only
|
| 711 |
wide_string wide_err_string; // exposition only
|
| 712 |
Codecvt* cvtptr; // exposition only
|
|
|
|
| 719 |
The class template describes an object that controls conversions between
|
| 720 |
wide string objects of class `std::basic_string<Elem, char_traits<Elem>,
|
| 721 |
Wide_alloc>` and byte string objects of class `std::\\basic_string<char,
|
| 722 |
char_traits<char>, Byte_alloc>`. The class template defines the types
|
| 723 |
`wide_string` and `byte_string` as synonyms for these two types.
|
| 724 |
+
Conversion between a sequence of `Elem` values (stored in a
|
| 725 |
+
`wide_string` object) and multibyte sequences (stored in a `byte_string`
|
| 726 |
+
object) is performed by an object of class `Codecvt`, which meets the
|
| 727 |
+
requirements of the standard code-conversion facet `std::codecvt<Elem,
|
|
|
|
| 728 |
char, std::mbstate_t>`.
|
| 729 |
|
| 730 |
An object of this class template stores:
|
| 731 |
|
| 732 |
- `byte_err_string` — a byte string to display on errors
|
|
|
|
| 735 |
freed when the `wstring_convert` object is destroyed)
|
| 736 |
- `cvtstate` — a conversion state object
|
| 737 |
- `cvtcount` — a conversion count
|
| 738 |
|
| 739 |
``` cpp
|
| 740 |
+
typedef std::basic_string<char, char_traits<char>, Byte_alloc> byte_string;
|
| 741 |
```
|
| 742 |
|
| 743 |
+
The type shall be a synonym for
|
| 744 |
+
`std::basic_string<char, char_traits<char>, Byte_alloc>`
|
| 745 |
|
| 746 |
``` cpp
|
| 747 |
+
size_t converted() const noexcept;
|
| 748 |
```
|
| 749 |
|
| 750 |
*Returns:* `cvtcount`.
|
| 751 |
|
| 752 |
``` cpp
|
|
|
|
| 822 |
constructed with a byte-error string, the member function shall return
|
| 823 |
the byte-error string. Otherwise, the member function shall throw an
|
| 824 |
object of class `std::range_error`.
|
| 825 |
|
| 826 |
``` cpp
|
| 827 |
+
typedef std::basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
|
| 828 |
```
|
| 829 |
|
| 830 |
+
The type shall be a synonym for
|
| 831 |
+
`std::basic_string<Elem, char_traits<Elem>, Wide_alloc>`.
|
| 832 |
|
| 833 |
``` cpp
|
| 834 |
+
explicit wstring_convert(Codecvt* pcvt = new Codecvt);
|
| 835 |
wstring_convert(Codecvt* pcvt, state_type state);
|
| 836 |
+
explicit wstring_convert(const byte_string& byte_err,
|
| 837 |
const wide_string& wide_err = wide_string());
|
| 838 |
```
|
| 839 |
|
| 840 |
+
*Requires:* For the first and second constructors, `pcvt != nullptr`.
|
| 841 |
+
|
| 842 |
*Effects:* The first constructor shall store `pcvt` in `cvtptr` and
|
| 843 |
default values in `cvtstate`, `byte_err_string`, and `wide_err_string`.
|
| 844 |
The second constructor shall store `pcvt` in `cvtptr`, `state` in
|
| 845 |
`cvtstate`, and default values in `byte_err_string` and
|
| 846 |
`wide_err_string`; moreover the stored state shall be retained between
|
|
|
|
| 870 |
class wbuffer_convert
|
| 871 |
: public std::basic_streambuf<Elem, Tr> {
|
| 872 |
public:
|
| 873 |
typedef typename Codecvt::state_type state_type;
|
| 874 |
|
| 875 |
+
explicit wbuffer_convert(std::streambuf* bytebuf = 0,
|
| 876 |
Codecvt* pcvt = new Codecvt,
|
| 877 |
state_type state = state_type());
|
| 878 |
|
| 879 |
+
~wbuffer_convert();
|
| 880 |
+
|
| 881 |
+
wbuffer_convert(const wbuffer_convert&) = delete;
|
| 882 |
+
wbuffer_convert& operator=(const wbuffer_convert&) = delete;
|
| 883 |
+
|
| 884 |
std::streambuf* rdbuf() const;
|
| 885 |
std::streambuf* rdbuf(std::streambuf* bytebuf);
|
| 886 |
|
| 887 |
state_type state() const;
|
| 888 |
|
|
|
|
| 896 |
|
| 897 |
The class template describes a stream buffer that controls the
|
| 898 |
transmission of elements of type `Elem`, whose character traits are
|
| 899 |
described by the class `Tr`, to and from a byte stream buffer of type
|
| 900 |
`std::streambuf`. Conversion between a sequence of `Elem` values and
|
| 901 |
+
multibyte sequences is performed by an object of class `Codecvt`, which
|
| 902 |
+
shall meet the requirements of the standard code-conversion facet
|
|
|
|
| 903 |
`std::codecvt<Elem, char, std::mbstate_t>`.
|
| 904 |
|
| 905 |
An object of this class template stores:
|
| 906 |
|
| 907 |
- `bufptr` — a pointer to its underlying byte stream buffer
|
|
|
|
| 934 |
```
|
| 935 |
|
| 936 |
The type shall be a synonym for `Codecvt::state_type`.
|
| 937 |
|
| 938 |
``` cpp
|
| 939 |
+
explicit wbuffer_convert(std::streambuf* bytebuf = 0,
|
| 940 |
Codecvt* pcvt = new Codecvt, state_type state = state_type());
|
| 941 |
```
|
| 942 |
|
| 943 |
+
*Requires:* `pcvt != nullptr`.
|
| 944 |
+
|
| 945 |
*Effects:* The constructor constructs a stream buffer object,
|
| 946 |
initializes `bufptr` to `bytebuf`, initializes `cvtptr` to `pcvt`, and
|
| 947 |
initializes `cvtstate` to `state`.
|
| 948 |
|
| 949 |
``` cpp
|
|
|
|
| 1507 |
The specializations required in Table
|
| 1508 |
[[tab:localization.category.facets]] ([[locale.category]]) convert the
|
| 1509 |
implementation-defined native character set.
|
| 1510 |
`codecvt<char, char, mbstate_t>` implements a degenerate conversion; it
|
| 1511 |
does not convert at all. The specialization `codecvt<char16_t,`
|
| 1512 |
+
`char, mbstate_t>` converts between the UTF-16 and UTF-8 encoding forms,
|
| 1513 |
+
and the specialization `codecvt` `<char32_t, char, mbstate_t>` converts
|
| 1514 |
+
between the UTF-32 and UTF-8 encoding forms.
|
| 1515 |
`codecvt<wchar_t,char,mbstate_t>` converts between the native character
|
| 1516 |
sets for narrow and wide characters. Specializations on `mbstate_t`
|
| 1517 |
perform conversion between encodings known to the library implementer.
|
| 1518 |
Other encodings can be converted by specializing on a user-defined
|
| 1519 |
+
`stateT` type. Objects of type `stateT` can contain any state that is
|
| 1520 |
+
useful to communicate to or from the specialized `do_in` or `do_out`
|
| 1521 |
+
members.
|
| 1522 |
|
| 1523 |
##### `codecvt` members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
|
| 1524 |
|
| 1525 |
``` cpp
|
| 1526 |
result out(stateT& state,
|
|
|
|
| 2334 |
`do_put(out, str, fill,`
|
| 2335 |
`(int)val)`, otherwise obtains a string `s` as if by
|
| 2336 |
|
| 2337 |
``` cpp
|
| 2338 |
string_type s =
|
| 2339 |
+
val ? use_facet<numpunct<charT>>(loc).truename()
|
| 2340 |
+
: use_facet<numpunct<charT>>(loc).falsename();
|
| 2341 |
```
|
| 2342 |
|
| 2343 |
and then inserts each character `c` of `s` into `out` via `*out++ = c`
|
| 2344 |
and returns `out`.
|
| 2345 |
|
|
|
|
| 2867 |
``` cpp
|
| 2868 |
iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
| 2869 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 2870 |
```
|
| 2871 |
|
| 2872 |
+
*Requires:* `t` shall point to an object.
|
| 2873 |
|
| 2874 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 2875 |
It then reads characters starting at `s` until it encounters an error,
|
| 2876 |
or until it has extracted and assigned those `struct tm` members, and
|
| 2877 |
any remaining format characters, corresponding to a conversion directive
|
|
|
|
| 3450 |
|
| 3451 |
``` cpp
|
| 3452 |
namespace std {
|
| 3453 |
class messages_base {
|
| 3454 |
public:
|
| 3455 |
+
typedef unspecified signed integer type catalog;
|
| 3456 |
};
|
| 3457 |
|
| 3458 |
template <class charT>
|
| 3459 |
class messages : public locale::facet, public messages_base {
|
| 3460 |
public:
|
|
|
|
| 3751 |
|
| 3752 |
template<class Elem, unsigned long Maxcode = 0x10ffff,
|
| 3753 |
codecvt_mode Mode = (codecvt_mode)0>
|
| 3754 |
class codecvt_utf8
|
| 3755 |
: public codecvt<Elem, char, mbstate_t> {
|
| 3756 |
+
public:
|
| 3757 |
+
explicit codecvt_utf8(size_t refs = 0);
|
| 3758 |
+
~codecvt_utf8();
|
| 3759 |
};
|
| 3760 |
|
| 3761 |
template<class Elem, unsigned long Maxcode = 0x10ffff,
|
| 3762 |
codecvt_mode Mode = (codecvt_mode)0>
|
| 3763 |
class codecvt_utf16
|
| 3764 |
: public codecvt<Elem, char, mbstate_t> {
|
| 3765 |
+
public:
|
| 3766 |
+
explicit codecvt_utf16(size_t refs = 0);
|
| 3767 |
+
~codecvt_utf16();
|
| 3768 |
};
|
| 3769 |
|
| 3770 |
template<class Elem, unsigned long Maxcode = 0x10ffff,
|
| 3771 |
codecvt_mode Mode = (codecvt_mode)0>
|
| 3772 |
class codecvt_utf8_utf16
|
| 3773 |
: public codecvt<Elem, char, mbstate_t> {
|
| 3774 |
+
public:
|
| 3775 |
+
explicit codecvt_utf8_utf16(size_t refs = 0);
|
| 3776 |
+
~codecvt_utf8_utf16();
|
| 3777 |
};
|
| 3778 |
}
|
| 3779 |
```
|
| 3780 |
|
| 3781 |
For each of the three code conversion facets `codecvt_utf8`,
|