1// { dg-require-iconv "UCS-2BE" } 2// { dg-require-iconv "ISO-8859-15" } 3// 2003-02-06 Petur Runolfsson <peturr02@ru.is> 4 5// Copyright (C) 2003-2015 Free Software Foundation, Inc. 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 10// Free Software Foundation; either version 3, or (at your option) 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 19// with this library; see the file COPYING3. If not see 20// <http://www.gnu.org/licenses/>. 21 22// 22.2.1.5 - Template class codecvt [lib.locale.codecvt] 23 24#include <locale> 25#include <cstring> 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) 32void 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 40 bool test __attribute__((unused)) = true; 41 const ext_type* e_lit = "black pearl jasmine tea"; 42 int size = strlen(e_lit); 43 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); 49 50 unicode_codecvt::state_type state04("UCS-2BE", "ISO-8859-15", 0xfeff, 0); 51 cvt.length(state04, e_lit, e_lit + size, 5); 52} 53 54int main () 55{ 56 test01(); 57 return 0; 58} 59