From dc75555ee9bcef06c011628adb6715c0fef9e15b Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Fri, 30 Oct 2026 19:30:32 -0500 Subject: [PATCH 1/2] G705: match Excel single-character casing --- crates/functions/src/text.rs | 37 ++++++++++++++++++++++++++++++++---- docs/function-parity.md | 3 ++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/crates/functions/src/text.rs b/crates/functions/src/text.rs index df125f022..a7b82b10a 100644 --- a/crates/functions/src/text.rs +++ b/crates/functions/src/text.rs @@ -111,12 +111,27 @@ fn len(a: &[Arg], _c: &mut dyn Ctx) -> R { num_val(text(a, 0)?.chars().count() as f64) } +fn lower_char(ch: char) -> char { + match ch.to_lowercase().next() { + Some(lower) => lower, + None => ch, + } +} + +fn upper_char(ch: char) -> char { + let mut uppercase = ch.to_uppercase(); + match uppercase.next() { + Some(upper) if uppercase.next().is_none() => upper, + _ => ch, + } +} + fn lower(a: &[Arg], _c: &mut dyn Ctx) -> R { - text_val(text(a, 0)?.to_lowercase()) + text_val(text(a, 0)?.chars().map(lower_char).collect()) } fn upper(a: &[Arg], _c: &mut dyn Ctx) -> R { - text_val(text(a, 0)?.to_uppercase()) + text_val(text(a, 0)?.chars().map(upper_char).collect()) } fn proper(a: &[Arg], _c: &mut dyn Ctx) -> R { @@ -126,9 +141,9 @@ fn proper(a: &[Arg], _c: &mut dyn Ctx) -> R { for ch in s.chars() { if ch.is_alphabetic() { if prev_letter { - out.extend(ch.to_lowercase()); + out.push(lower_char(ch)); } else { - out.extend(ch.to_uppercase()); + out.push(upper_char(ch)); } prev_letter = true; } else { @@ -1123,6 +1138,20 @@ mod tests { fn case_and_cleanup() { is_text(ev("UPPER", vec![t("abc")]), "ABC"); is_text(ev("LOWER", vec![t("ABC")]), "abc"); + is_text(ev("UPPER", vec![t("Straße")]), "STRAßE"); + is_text(ev("LOWER", vec![t("İ")]), "i"); + is_text(ev("PROPER", vec![t("İSTANBUL")]), "Istanbul"); + is_text(ev("PROPER", vec![t("ß")]), "ß"); + is_text(ev("PROPER", vec![t("ÉCOLE")]), "École"); + let proper = ev("PROPER", vec![t("İSTANBUL Straße")]); + is_text(proper.clone(), "Istanbul Straße"); + assert_eq!( + match proper { + Value::Text(s) => s.chars().count(), + _ => 0, + }, + "Istanbul Straße".chars().count() + ); is_text(ev("PROPER", vec![t("this is a TITLE")]), "This Is A Title"); is_text(ev("PROPER", vec![t("2-way street's")]), "2-Way Street'S"); is_text(ev("TRIM", vec![t(" a b c ")]), "a b c"); diff --git a/docs/function-parity.md b/docs/function-parity.md index bf57fcd3e..44a1ed08e 100644 --- a/docs/function-parity.md +++ b/docs/function-parity.md @@ -1,6 +1,6 @@ # Function parity: worksheet functions and formulas -> **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-25 · **Change:** minor (the LAMBDA row lists the recursion limit and its `#NUM!`, and the error a defined name holding an error gives when called; earlier: number text with accounting parentheses coerces like Excel 365; INDEX with one index on a 2-D reference is #REF! as in Excel; earlier: SUBTOTAL and AGGREGATE cap the cells they visit, #2175) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 +> **Last reviewed:** 2026-10-31 · **Last updated:** 2026-10-31 · **Change:** minor (UPPER, LOWER and PROPER use single-character Unicode casing to match measured Excel results; locale check: Windows Excel 16.0 build 20527, LCID 1033) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4 Excel's worksheet functions, category by category, against GridCraft's function library. Part of [target-app-parity.md](target-app-parity.md); gaps feed [gaps.md](gaps.md). @@ -123,6 +123,7 @@ workbooks; results checked in as data, not Excel files) and fixing what it finds | Date | Change | Summary | |---|---|---| +| 2026-10-31 | minor | UPPER, LOWER and PROPER use single-character casing: `UPPER("Straße")` keeps ß, `LOWER("İ")` returns i, and `PROPER("İSTANBUL")` returns Istanbul, matching Windows Excel 16.0 build 20527 in LCID 1033 | | 2026-10-25 | minor | LAMBDA row: a LAMBDA that calls itself more than 140 times, and a formula nested past the depth limit, give `#NUM!` (#1809; nesting gave `#CALC!` before). `=Foo(1)` where the defined name Foo holds `#N/A` gives `#N/A`, not `#NAME?` | | 2026-10-23 | minor | Number text coercion (VALUE, arithmetic, typed entry): a dollar sign before accounting parentheses (`$(1,234)`, `$ (5)`) and a percent sign after them (`(5)%`) read as negatives; `(-5)`, `((5))`, `($-5)`, `$5%`, `$(5)%` and dates or times in parentheses are `#VALUE!`, as observed in Excel 365 | | 2026-10-23 | minor | INDEX with only a row index on a reference of several rows and columns (`INDEX(A1:C3,2)`, `INDEX(A1:C3,0)`) is `#REF!`, as observed in Excel, so it also fails as a range endpoint and inside other functions; an empty column argument (`INDEX(A1:C3,2,)`) still gives the row. Checked that a column array with one index stays a 1×1 array (`TYPE` 64), which is what Excel returns | From 32dbf6a2244eb2c269585f6c2f752c753db48dc8 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Fri, 30 Oct 2026 19:37:03 -0500 Subject: [PATCH 2/2] G705: fix single-character case conversions --- crates/functions/src/text.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/functions/src/text.rs b/crates/functions/src/text.rs index a7b82b10a..d056b6ef9 100644 --- a/crates/functions/src/text.rs +++ b/crates/functions/src/text.rs @@ -126,12 +126,16 @@ fn upper_char(ch: char) -> char { } } +fn proper_upper_char(ch: char) -> char { + if ch == '\u{130}' { 'I' } else { upper_char(ch) } +} + fn lower(a: &[Arg], _c: &mut dyn Ctx) -> R { - text_val(text(a, 0)?.chars().map(lower_char).collect()) + text_val(text(a, 0)?.chars().map(lower_char).collect::()) } fn upper(a: &[Arg], _c: &mut dyn Ctx) -> R { - text_val(text(a, 0)?.chars().map(upper_char).collect()) + text_val(text(a, 0)?.chars().map(upper_char).collect::()) } fn proper(a: &[Arg], _c: &mut dyn Ctx) -> R { @@ -143,7 +147,7 @@ fn proper(a: &[Arg], _c: &mut dyn Ctx) -> R { if prev_letter { out.push(lower_char(ch)); } else { - out.push(upper_char(ch)); + out.push(proper_upper_char(ch)); } prev_letter = true; } else {