mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
refactor(managed): reuse the BOM-preserving UTF-8 decoder (#16228)
This commit is contained in:
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 = (
|
||||
|
||||
Reference in new issue
Block a user