refactor(managed): reuse the BOM-preserving UTF-8 decoder (#16228)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-03 05:13:17 +00:00
1 parent dc6f34cad7
commit 7a2fa449a9
1 file changed
+2 -8
@@ -1,5 +1,5 @@
import { BinaryReader } from "../binaryContainer.js";
import { decodeStrictUtf8 } from "../strictUtf8.js";
import { decodeUtf8PreservingBomOrNull } from "../strictUtf8.js";
import { readMemberReferenceRowFacts } from "./managedMemberReferenceRows.js";
import { readTypeDefinitionRowFacts } from "./managedTypeDefinitionRows.js";
import { managedDecodeBudget } from "./managedDecodeBudget.js";
@@ -417,13 +417,7 @@ const decodeFixedString = (
const start = 2 + width;
if (start > blob.length - length) return null;
managedDecodeBudget(layout).reserveString(length, metadataBlobOffset(layout));
try {
return decodeStrictUtf8(blob.subarray(start, start + length), "preserve");
} catch (cause: unknown) {
// Invalid UTF-8 blobs decode as null.
void cause;
return null;
}
return decodeUtf8PreservingBomOrNull(blob.subarray(start, start + length));
};
export const readCustomAttribute = (