Windows port for __codecvt_utf8<wchar_t>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d712a59c7f
commit
0769e6a785
@ -3201,14 +3201,25 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,
|
|||||||
const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
|
const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
|
||||||
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
|
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
|
||||||
{
|
{
|
||||||
|
#if _WIN32
|
||||||
|
const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
|
||||||
|
const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
|
||||||
|
const uint16_t* _frm_nxt = _frm;
|
||||||
|
#else
|
||||||
const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
|
const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
|
||||||
const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
|
const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
|
||||||
const uint32_t* _frm_nxt = _frm;
|
const uint32_t* _frm_nxt = _frm;
|
||||||
|
#endif
|
||||||
uint8_t* _to = reinterpret_cast<uint8_t*>(to);
|
uint8_t* _to = reinterpret_cast<uint8_t*>(to);
|
||||||
uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
|
uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
|
||||||
uint8_t* _to_nxt = _to;
|
uint8_t* _to_nxt = _to;
|
||||||
|
#if _WIN32
|
||||||
|
result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
|
||||||
|
_Maxcode_, _Mode_);
|
||||||
|
#else
|
||||||
result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
|
result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
|
||||||
_Maxcode_, _Mode_);
|
_Maxcode_, _Mode_);
|
||||||
|
#endif
|
||||||
frm_nxt = frm + (_frm_nxt - _frm);
|
frm_nxt = frm + (_frm_nxt - _frm);
|
||||||
to_nxt = to + (_to_nxt - _to);
|
to_nxt = to + (_to_nxt - _to);
|
||||||
return r;
|
return r;
|
||||||
@ -3222,11 +3233,19 @@ __codecvt_utf8<wchar_t>::do_in(state_type&,
|
|||||||
const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
|
const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
|
||||||
const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
|
const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
|
||||||
const uint8_t* _frm_nxt = _frm;
|
const uint8_t* _frm_nxt = _frm;
|
||||||
|
#if _WIN32
|
||||||
|
uint16_t* _to = reinterpret_cast<uint16_t*>(to);
|
||||||
|
uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
|
||||||
|
uint16_t* _to_nxt = _to;
|
||||||
|
result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
|
||||||
|
_Maxcode_, _Mode_);
|
||||||
|
#else
|
||||||
uint32_t* _to = reinterpret_cast<uint32_t*>(to);
|
uint32_t* _to = reinterpret_cast<uint32_t*>(to);
|
||||||
uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
|
uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
|
||||||
uint32_t* _to_nxt = _to;
|
uint32_t* _to_nxt = _to;
|
||||||
result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
|
result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
|
||||||
_Maxcode_, _Mode_);
|
_Maxcode_, _Mode_);
|
||||||
|
#endif
|
||||||
frm_nxt = frm + (_frm_nxt - _frm);
|
frm_nxt = frm + (_frm_nxt - _frm);
|
||||||
to_nxt = to + (_to_nxt - _to);
|
to_nxt = to + (_to_nxt - _to);
|
||||||
return r;
|
return r;
|
||||||
|
@ -45,14 +45,14 @@ int main()
|
|||||||
test_buf f(bs.rdbuf());
|
test_buf f(bs.rdbuf());
|
||||||
assert(f.sbumpc() == L'1');
|
assert(f.sbumpc() == L'1');
|
||||||
assert(f.sgetc() == L'2');
|
assert(f.sgetc() == L'2');
|
||||||
assert(f.pbackfail(L'a') == -1);
|
assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::fstream bs("underflow.dat");
|
std::fstream bs("underflow.dat");
|
||||||
test_buf f(bs.rdbuf());
|
test_buf f(bs.rdbuf());
|
||||||
assert(f.sbumpc() == L'1');
|
assert(f.sbumpc() == L'1');
|
||||||
assert(f.sgetc() == L'2');
|
assert(f.sgetc() == L'2');
|
||||||
assert(f.pbackfail(L'a') == -1);
|
assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
|
||||||
assert(f.sbumpc() == L'2');
|
assert(f.sbumpc() == L'2');
|
||||||
assert(f.sgetc() == L'3');
|
assert(f.sgetc() == L'3');
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,6 @@ int main()
|
|||||||
assert(f.sbumpc() == 0x4E51);
|
assert(f.sbumpc() == 0x4E51);
|
||||||
assert(f.sbumpc() == 0x4E52);
|
assert(f.sbumpc() == 0x4E52);
|
||||||
assert(f.sbumpc() == 0x4E53);
|
assert(f.sbumpc() == 0x4E53);
|
||||||
assert(f.sbumpc() == -1);
|
assert(f.sbumpc() == test_buf::traits_type::eof());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user