(encoding: string, data: Uint8Array)
| 275 | } |
| 276 | |
| 277 | const validatesHeuristicEncoding = (encoding: string, data: Uint8Array): boolean => { |
| 278 | try { |
| 279 | const sample = data.subarray(0, Math.min(HEURISTIC_VALIDATE_LIMIT, data.length)); |
| 280 | const decoded = bytesDecode(encoding, sample); |
| 281 | return !hasSuspiciousDecodedControlChars(decoded); |
| 282 | } catch { |
| 283 | return false; |
| 284 | } |
| 285 | }; |
| 286 | |
| 287 | /** |
| 288 | * Reads a Blob or File or Uint8Array with reasonably good encoding detection |
no test coverage detected