(charset: string, bytes: Uint8Array)
| 34 | }; |
| 35 | |
| 36 | export 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 | |
| 47 | const unicodeEncodings = new Set(["utf-8", "ascii", "utf-16le", "utf-16be", "utf-32le", "utf-32be"]); |
| 48 |