From 1d07b6a592558b80cf23f3bea1d6103e6f45a0b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:08:42 +0000 Subject: [PATCH 1/2] Initial plan From 9305e6b6ff48af3c8180d174a10c1f88f2d05706 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:17:55 +0000 Subject: [PATCH 2/2] Fix UTF-32 surrogate handling bug Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com> --- fallback/utf32.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/fallback/utf32.js b/fallback/utf32.js index 7edf18ca..85045334 100644 --- a/fallback/utf32.js +++ b/fallback/utf32.js @@ -51,18 +51,10 @@ export function toWellFormed(u32) { for (let i = 0; i < length; i++) { const x = u32[i] if (x >= 0xd8_00) { + // In UTF-32, all surrogate codepoints (0xD800-0xDFFF) are invalid + // Unlike UTF-16, there are no surrogate pairs in UTF-32 if (x < 0xe0_00) { - // An unexpected trail or a lead at the very end of input - if (x > 0xdb_ff || i + 1 >= length) { - u32[i] = replacementCodepoint - } else { - const next = u32[i + 1] // Process valid pairs immediately - if (next < 0xdc_00 || next >= 0xe0_00) { - u32[i] = replacementCodepoint - } else { - i++ // consume next - } - } + u32[i] = replacementCodepoint } else if (x >= 0x11_00_00) { // also fix out-of-range in the same pass, both are unlikely u32[i] = replacementCodepoint