diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-16 15:28:02 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-16 15:28:02 +0000 |
commit | 0297caac35a264c5f55302607a4666365ebd56a5 (patch) | |
tree | db2ed66b6f2e7d0be362185cae557fa867c2d319 /libstdc++-v3/src | |
parent | f5861b7ed65f27ddd549f27402b89c031317665f (diff) | |
download | gcc-0297caac35a264c5f55302607a4666365ebd56a5.tar.gz |
PR libstdc++/80041 fix codecvt_utf16<wchar_t> to use UTF-16 not UTF-8
PR libstdc++/80041
* src/c++11/codecvt.cc (__codecvt_utf16_base<wchar_t>::do_out)
(__codecvt_utf16_base<wchar_t>::do_in): Convert char arguments to
char16_t to work with UTF-16 instead of UTF-8.
* testsuite/22_locale/codecvt/codecvt_utf16/80041.cc: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@246202 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r-- | libstdc++-v3/src/c++11/codecvt.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc index 9c917257567..ef38267e855 100644 --- a/libstdc++-v3/src/c++11/codecvt.cc +++ b/libstdc++-v3/src/c++11/codecvt.cc @@ -1217,7 +1217,10 @@ do_out(state_type&, const intern_type* __from, const intern_type* __from_end, extern_type* __to, extern_type* __to_end, extern_type*& __to_next) const { - range<char> to{ __to, __to_end }; + range<char16_t> to{ + reinterpret_cast<char16_t*>(__to), + reinterpret_cast<char16_t*>(__to_end) + }; #if __SIZEOF_WCHAR_T__ == 2 range<const char16_t> from{ reinterpret_cast<const char16_t*>(__from), @@ -1234,7 +1237,7 @@ do_out(state_type&, const intern_type* __from, const intern_type* __from_end, return codecvt_base::error; #endif __from_next = reinterpret_cast<const wchar_t*>(from.next); - __to_next = to.next; + __to_next = reinterpret_cast<char*>(to.next); return res; } @@ -1254,7 +1257,10 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end, intern_type* __to, intern_type* __to_end, intern_type*& __to_next) const { - range<const char> from{ __from, __from_end }; + range<const char16_t> from{ + reinterpret_cast<const char16_t*>(__from), + reinterpret_cast<const char16_t*>(__from_end) + }; #if __SIZEOF_WCHAR_T__ == 2 range<char16_t> to{ reinterpret_cast<char16_t*>(__to), @@ -1270,7 +1276,7 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end, #else return codecvt_base::error; #endif - __from_next = from.next; + __from_next = reinterpret_cast<const char*>(from.next); __to_next = reinterpret_cast<wchar_t*>(to.next); return res; } |