diff --git a/src/sqlite/SqliteDatabaseInspection.ts b/src/sqlite/SqliteDatabaseInspection.ts index 8e4e22634a9..de687339932 100644 --- a/src/sqlite/SqliteDatabaseInspection.ts +++ b/src/sqlite/SqliteDatabaseInspection.ts @@ -360,29 +360,8 @@ const asciiLower = ( bytes: Uint8Array, encoding: DatabaseEncoding, ): string | undefined => { - if (encoding === "UTF-8") { - let text = ""; - for (const byte of bytes) { - if (byte >= 0x80) return undefined; - text += String.fromCharCode( - byte >= 0x41 && byte <= 0x5a ? byte + 0x20 : byte, - ); - } - return text; - } - if (bytes.length % 2 !== 0) return undefined; - const lowFirst = encoding === "UTF-16le"; - let text = ""; - for (let index = 0; index < bytes.length; index += 2) { - const unit = lowFirst - ? bytes[index]! | (bytes[index + 1]! << 8) - : (bytes[index]! << 8) | bytes[index + 1]!; - if (unit >= 0x80) return undefined; - text += String.fromCharCode( - unit >= 0x41 && unit <= 0x5a ? unit + 0x20 : unit, - ); - } - return text; + const text = LENIENT_TEXT_DECODERS[encoding].decode(bytes); + return /\P{ASCII}/u.test(text) ? undefined : text.toLowerCase(); }; const readPrimaryKeyIndexName = (