]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix handling of field width for wide strings and characters [PR119593]
authorTomasz Kamiński <tkaminsk@redhat.com>
Thu, 3 Apr 2025 08:23:45 +0000 (10:23 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Thu, 3 Apr 2025 12:31:43 +0000 (14:31 +0200)
commitad1b71fc2882c14271ebf2bbaf216cceaa88c76a
treee5c74522ba9efb1780880872fa1efce288a8aeac
parentf955c5b409a96bd12765680517ce583d7086c62d
libstdc++: Fix handling of field width for wide strings and characters [PR119593]

This patch corrects handling of UTF-32LE and UTF32-BE in
__unicode::__literal_encoding_is_unicode<_CharT>, so they are
recognized as unicode and functions produces correct result for wchar_t.

Use `__unicode::__field_width` to compute the estimated witdh
of the charcter for unicode wide encoding.

PR libstdc++/119593

libstdc++-v3/ChangeLog:

* include/bits/unicode.h
(__unicode::__literal_encoding_is_unicode<_CharT>):
Corrected handing for UTF-16 and UTF-32 with "LE" or "BE" suffix.
* include/std/format (__formatter_str::_S_character_width):
Define.
(__formatter_str::_S_character_width): Updated passed char
length.
* testsuite/std/format/functions/format.cc: Test for wchar_t.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/bits/unicode.h
libstdc++-v3/include/std/format
libstdc++-v3/testsuite/std/format/functions/format.cc