d23b464e21
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@105254 91177308-0d34-0410-b5e6-96231b3b80d8
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <locale>
|
|
|
|
// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
|
|
|
|
// byte_string to_bytes(Elem wchar);
|
|
// byte_string to_bytes(const Elem* wptr);
|
|
// byte_string to_bytes(const wide_string& wstr);
|
|
// byte_string to_bytes(const Elem* first, const Elem* last);
|
|
|
|
#include <locale>
|
|
#include <codecvt>
|
|
#include <cassert>
|
|
|
|
int main()
|
|
{
|
|
{
|
|
std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
|
|
std::wstring ws(1, L'\x40003');
|
|
std::string bs = myconv.to_bytes(ws[0]);
|
|
assert(bs == "\xF1\x80\x80\x83");
|
|
bs = myconv.to_bytes(ws.c_str());
|
|
assert(bs == "\xF1\x80\x80\x83");
|
|
bs = myconv.to_bytes(ws);
|
|
assert(bs == "\xF1\x80\x80\x83");
|
|
bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
|
|
assert(bs == "\xF1\x80\x80\x83");
|
|
}
|
|
}
|