MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / bytesDecode

Function bytesDecode

src/pkg/utils/encoding.ts:36–45  ·  view source on GitHub ↗
(charset: string, bytes: Uint8Array)

Source from the content-addressed store, hash-verified

34};
35
36export const bytesDecode = (charset: string, bytes: Uint8Array): string => {
37 const normalizedCharset = charset.toLowerCase();
38 if (normalizedCharset === "utf-32le") {
39 return decodeUTF32(bytes, true);
40 } else if (normalizedCharset === "utf-32be") {
41 return decodeUTF32(bytes, false);
42 } else {
43 return new TextDecoder(normalizedCharset).decode(bytes);
44 }
45};
46
47const unicodeEncodings = new Set(["utf-8", "ascii", "utf-16le", "utf-16be", "utf-32le", "utf-32be"]);
48

Callers 5

encoding.test.tsFile · 0.90
legacyDetectEncodingFunction · 0.85
readRawContentFunction · 0.85

Calls 1

decodeUTF32Function · 0.85

Tested by 1