| 1 |
// Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// { dg-do run { target c++11 } } |
| 19 |
|
| 20 |
// libstdc++/66441 |
| 21 |
|
| 22 |
#include <locale> |
| 23 |
#include <codecvt> |
| 24 |
#include <testsuite_hooks.h> |
| 25 |
|
| 26 |
void |
| 27 |
test01() |
| 28 |
{ |
| 29 |
// convert from UCS-4 to UTF16BE with BOM. |
| 30 |
using cvt = std::codecvt_utf16<char32_t, 0x10FFFF, std::generate_header>; |
| 31 |
std::wstring_convert<cvt, char32_t> conv; |
| 32 |
// { dg-warning "deprecated" "" { target c++17 } 31 } |
| 33 |
auto to = conv.to_bytes(U"ab\u00e7"); |
| 34 |
|
| 35 |
VERIFY( to.length() == 8 ); |
| 36 |
VERIFY( (unsigned char)to[0] == 0xfe ); |
| 37 |
VERIFY( (unsigned char)to[1] == 0xff ); |
| 38 |
VERIFY( (unsigned char)to[2] == 0x00 ); |
| 39 |
VERIFY( (unsigned char)to[3] == 0x61 ); |
| 40 |
VERIFY( (unsigned char)to[4] == 0x00 ); |
| 41 |
VERIFY( (unsigned char)to[5] == 0x62 ); |
| 42 |
VERIFY( (unsigned char)to[6] == 0x00 ); |
| 43 |
VERIFY( (unsigned char)to[7] == 0xe7 ); |
| 44 |
} |
| 45 |
|
| 46 |
int |
| 47 |
main() |
| 48 |
{ |
| 49 |
test01(); |
| 50 |
} |