From e604dcd94e4fc1627ca800acf8cf1094e4a68b5d Mon Sep 17 00:00:00 2001 From: Kainoa Kanter Date: Tue, 24 Mar 2026 01:57:08 -0400 Subject: [PATCH] fix: better mojibake detection for lone multi-byte lead (#1247) --- src/cli/components/Text.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cli/components/Text.tsx b/src/cli/components/Text.tsx index 7a62baf..ba5f3f0 100644 --- a/src/cli/components/Text.tsx +++ b/src/cli/components/Text.tsx @@ -37,6 +37,13 @@ function looksLikeMojibake(value: string): boolean { } } + // A lone multi-byte lead with even one valid continuation is mojibake + if (byte >= 0xc2 && byte <= 0xf4) { + if (i + 1 < value.length && isContinuationByte(value.charCodeAt(i + 1))) { + sawUtf8Sequence = true; + } + } + if (byte >= 0xf0 && byte <= 0xf4) { if ( i + 3 < value.length &&