1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <locale> 10 11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS 12 13 // wbuffer_convert<Codecvt, Elem, Tr> 14 15 // XFAIL: no-wide-characters 16 17 #include <fstream> 18 #include <locale> 19 #include <codecvt> 20 #include <cassert> 21 22 #include "test_macros.h" 23 24 int main(int, char**) 25 { 26 { 27 std::ofstream bytestream("myfile.txt"); 28 std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf()); 29 std::wostream mystr(&mybuf); 30 mystr << L"Hello" << std::endl; 31 } 32 { 33 std::ifstream bytestream("myfile.txt"); 34 std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf()); 35 std::wistream mystr(&mybuf); 36 std::wstring ws; 37 mystr >> ws; 38 assert(ws == L"Hello"); 39 } 40 std::remove("myfile.txt"); 41 42 return 0; 43 } 44