]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix Unicode codecvt and add tests [PR86419]
authorDimitrij Mijoski <dmjpp@hotmail.com>
Tue, 10 Jan 2023 12:58:59 +0000 (13:58 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:50:52 +0000 (13:50 +0000)
commit12c193e5723f08694c8784457200112bae117063
treebb61f8e7de4101ed46caa8012c94cca927aef6d8
parentbfa7e7dfc19e07bff319636cf1bdfd57b6c68f41
libstdc++: Fix Unicode codecvt and add tests [PR86419]

Fixes the conversion from UTF-8 to UTF-16 to properly return partial
instead ok.
Fixes the conversion from UTF-16 to UTF-8 to properly return partial
instead ok.
Fixes the conversion from UTF-8 to UCS-2 to properly return partial
instead error.
Fixes the conversion from UTF-8 to UCS-2 to treat 4-byte UTF-8 sequences
as error just by seeing the leading byte.
Fixes UTF-8 decoding for all codecvts so they detect error at the end of
the input range when the last code point is also incomplete.

libstdc++-v3/ChangeLog:

PR libstdc++/86419
* src/c++11/codecvt.cc (read_utf8_code_point): Correctly detect
errors in incomplete multibyte sequences.
(utf16_in): Remove surrogates parameter. Fix conditions for
returning partial.
(utf16_out): Fix condition for returning partial.
(ucs2_in): Do not pass surrogates argument to utf16_in.
* testsuite/22_locale/codecvt/codecvt_unicode.cc: New test.
* testsuite/22_locale/codecvt/codecvt_unicode.h: New header for
tests.
* testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: New
test.

(cherry picked from commit 02dab998665dda0f6df31740e8897c42de3d740f)
libstdc++-v3/src/c++11/codecvt.cc
libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc [new file with mode: 0644]
This page took 0.060207 seconds and 6 git commands to generate.