Eduardo Gómez d0cec7ae2e
Fix inconsistent display width for emoji outside East Asian Wide ranges (#4896)
* Widen display_width_of() to cover Emoji_Presentation code points

fmt::detail::display_width_of() only treated East Asian Wide/Fullwidth
code points and two hand-picked emoji ranges as two columns wide, so
emoji outside those ranges (e.g. the Dingbats block: cross mark U+274C,
white heavy check mark U+2705) were measured as one column even though
most terminals render them double-width. This produced visibly
inconsistent padding under {:^N} compared to CJK text (fixes #4851).

Replaced the ad hoc boolean expression with a sorted table of ranges
(East Asian Wide/Fullwidth plus the full Emoji_Presentation set from
Unicode's emoji-data.txt) looked up via binary search, and added
regression tests covering the original report plus edge cases:
multiple emoji, mixed emoji/CJK/ASCII content, precision truncation,
alignment/fill variants, newly covered emoji ranges, and regional
indicator (flag) pairs.

* Make wide_cp_ranges C++11-compatible; apply clang-format

* Move wide_cp_range struct into display_width_of()

* Derive wide_cp_ranges from East_Asian_Width data, restore constexpr

* Move wide_cp_ranges to display_width_of function body

* Update format.h

* Update wide_cp_ranges array to include comments

* Add inline to display_width_of and add 1F300-1F5FF and 1F900-1F9FF ranges to match [format.string.std]

* Update display_width_of lo hi varible declaration

---------

Co-authored-by: Eduardo Gomez Saldias <50159560+edugomez102@users.noreply.github.com>
2026-08-30 08:05:50 -07:00
..
add-subdirectory-test Apply clang-format 2026-07-23 13:10:37 -07:00
compile-error-test Avoid dropping null byte in format string (#4732) 2026-04-23 09:34:27 -07:00
cuda-test Apply cmake-format 2026-03-03 15:49:40 -08:00
find-package-test Bump tested CMake version to 3.25 2022-11-30 08:09:32 -08:00
fuzzing Apply cmake-format 2026-03-03 15:49:40 -08:00
gtest Apply cmake-format 2026-03-03 15:49:40 -08:00
static-export-test Bump tested CMake version to 3.25 2022-11-30 08:09:32 -08:00
args-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
assert-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
base-test.cc Simplify test 2026-06-26 12:29:26 -07:00
c-test.c Add a test for fmt_print 2026-06-08 08:18:43 +02:00
chrono-test.cc fix out-of-range float to int conversion in to_nonnegative_int (#4802) 2026-06-16 23:14:58 -07:00
CMakeLists.txt Stop enabling C++26 reflection by default 2026-08-29 16:28:09 -07:00
color-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
compile-test.cc Handle const-qualified named arguments 2026-07-29 09:20:23 -07:00
detect-stdfs.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
enforce-checks-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
enum-test.cc Look up sparse enum identifiers in a hash table instead of a linear search (#4899) 2026-08-29 07:47:28 -07:00
format-impl-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
format-test.cc Fix inconsistent display width for emoji outside East Asian Wide ranges (#4896) 2026-08-30 08:05:50 -07:00
gtest-extra-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
gtest-extra.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
gtest-extra.h Unify copyright notices 2026-05-31 08:54:06 -07:00
header-only-test.cc Add base.h 2024-01-09 19:36:12 -08:00
mock-allocator.h Unify copyright notices 2026-05-31 08:54:06 -07:00
module-test.cc Format enums annotated with fmt::as_identifiers (requires C++26 reflection) (#4885) 2026-08-23 09:31:28 -07:00
no-builtin-types-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
noexception-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
os-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
ostream-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
perf-sanity.cc Cleanup test 2024-07-17 06:59:24 -07:00
posix-mock-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
posix-mock.h Unify copyright notices 2026-05-31 08:54:06 -07:00
printf-test.cc fix out-of-bounds read in basic_format_args::get (#4800) 2026-06-09 22:18:35 -07:00
ranges-odr-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
ranges-test.cc Fix ambiguous formatter<std::optional<T>> between fmt/std.h and fmt/ranges.h on C++26 (P3168R2) (#4761) 2026-05-03 07:37:46 -07:00
scan-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
scan.h Unify copyright notices 2026-05-31 08:54:06 -07:00
std-test.cc Reject sign-aware zero padding in std::exception and error_code formatters 2026-08-16 10:00:41 -07:00
test-assert.h Unify copyright notices 2026-05-31 08:54:06 -07:00
test-main.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
unicode-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
util.cc Unify copyright notices 2026-05-31 08:54:06 -07:00
util.h Unify copyright notices 2026-05-31 08:54:06 -07:00
xchar-test.cc Unify copyright notices 2026-05-31 08:54:06 -07:00