From 32f8e2c2ad77bf98a9631ab86eff70db7db8aae4 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:31:48 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20spurious=20=E9=9B=B6=20after=20a=20group'?= =?UTF-8?q?s=20trailing=20zeros=20in=20Chinese=20numerals=20(#3745)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found while testing crates/doc/src/cjk_numbers.rs:47-55 (Counting::format) Co-authored-by: Claude Haiku 5.5 --- crates/doc/src/cjk_numbers.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/doc/src/cjk_numbers.rs b/crates/doc/src/cjk_numbers.rs index 64a1757fa..f3b6585c4 100644 --- a/crates/doc/src/cjk_numbers.rs +++ b/crates/doc/src/cjk_numbers.rs @@ -74,6 +74,8 @@ impl Counting { out.push(u); } } + // Trailing zeros of a group are not a gap: the next group starts a new place. + zero_pending = false; match gi { 0 => out.extend(self.myriads.get(1)), 1 => out.extend(self.myriads.first()), @@ -324,6 +326,17 @@ pub(crate) fn chosung(n: u32) -> String { mod tests { use super::*; + #[test] + fn chinese_no_zero_after_group_trailing_zeros() { + assert_eq!(chinese_counting_thousand(201_000), "二十万一千"); + assert_eq!(chinese_counting_thousand(120_000), "十二万"); + assert_eq!(chinese_counting_thousand(100_100), "十万零一百"); + assert_eq!(taiwanese_counting_thousand(201_000), "二十萬一千"); + assert_eq!(chinese_counting_thousand(100_000_001), "一亿零一"); + assert_eq!(chinese_counting_thousand(100_010_000), "一亿零一万"); + assert_eq!(chinese_counting_thousand(120_000_001), "一亿二千万零一"); + } + #[test] fn chinese_counting_systems() { let c = |n| chinese_counting(n);