1 // { dg-require-iconv "UCS-2BE" }
2 // { dg-require-iconv "ISO-8859-15" }
3 // 2003-02-06 Petur Runolfsson <peturr02@ru.is>
5 // Copyright (C) 2003, 2007 Free Software Foundation
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
10 // Free Software Foundation; either version 2, or (at your option)
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.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 // 22.2.1.5 - Template class codecvt [lib.locale.codecvt]
26 #include <testsuite_hooks.h>
27 #include <ext/codecvt_specializations.h>
29 // Partial specialization using encoding_state
30 // codecvt<unicode_t, char, encoding_state>
31 // UNICODE - UCS2 (big endian)
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;
40 bool test __attribute__((unused)) = true;
41 const ext_type* e_lit = "black pearl jasmine tea";
42 int size = strlen(e_lit);
44 // construct a locale object with the specialized facet.
45 locale loc(locale::classic(), new unicode_codecvt);
46 // sanity check the constructed locale has the specialized facet.
47 VERIFY( has_facet<unicode_codecvt>(loc) );
48 const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
50 unicode_codecvt::state_type state04("UCS-2BE", "ISO-8859-15", 0xfeff, 0);
51 cvt.length(state04, e_lit, e_lit + size, 5);