]>
Commit | Line | Data |
---|---|---|
4ffe6e87 BK |
1 | // { dg-require-iconv "UCS-2BE" } |
2 | // { dg-require-iconv "ISO-8859-15" } | |
3 | // 2003-02-06 Petur Runolfsson <peturr02@ru.is> | |
4 | ||
99dee823 | 5 | // Copyright (C) 2003-2021 Free Software Foundation, Inc. |
4ffe6e87 BK |
6 | // |
7 | // This file is part of the GNU ISO C++ Library. This library is free | |
8 | // software; you can redistribute it and/or modify it under the | |
9 | // terms of the GNU General Public License as published by the | |
748086b7 | 10 | // Free Software Foundation; either version 3, or (at your option) |
4ffe6e87 BK |
11 | // any later version. |
12 | ||
13 | // This library is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | ||
18 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
19 | // with this library; see the file COPYING3. If not see |
20 | // <http://www.gnu.org/licenses/>. | |
4ffe6e87 BK |
21 | |
22 | // 22.2.1.5 - Template class codecvt [lib.locale.codecvt] | |
23 | ||
24 | #include <locale> | |
1b716e90 | 25 | #include <cstring> |
4ffe6e87 BK |
26 | #include <testsuite_hooks.h> |
27 | #include <ext/codecvt_specializations.h> | |
28 | ||
29 | // Partial specialization using encoding_state | |
30 | // codecvt<unicode_t, char, encoding_state> | |
31 | // UNICODE - UCS2 (big endian) | |
32 | void test01() | |
33 | { | |
34 | using namespace std; | |
35 | typedef unsigned short int_type; | |
36 | typedef char ext_type; | |
37 | typedef __gnu_cxx::encoding_state state_type; | |
38 | typedef codecvt<int_type, ext_type, state_type> unicode_codecvt; | |
39 | ||
4ffe6e87 BK |
40 | const ext_type* e_lit = "black pearl jasmine tea"; |
41 | int size = strlen(e_lit); | |
42 | ||
43 | // construct a locale object with the specialized facet. | |
44 | locale loc(locale::classic(), new unicode_codecvt); | |
45 | // sanity check the constructed locale has the specialized facet. | |
46 | VERIFY( has_facet<unicode_codecvt>(loc) ); | |
47 | const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc); | |
48 | ||
49 | unicode_codecvt::state_type state04("UCS-2BE", "ISO-8859-15", 0xfeff, 0); | |
50 | cvt.length(state04, e_lit, e_lit + size, 5); | |
51 | } | |
52 | ||
53 | int main () | |
54 | { | |
55 | test01(); | |
56 | return 0; | |
57 | } |