(charset)
| 16 | * @returns {Encoding|undefined} |
| 17 | */ |
| 18 | export function getEncoding(charset) { |
| 19 | charset = charset.toLowerCase(); |
| 20 | |
| 21 | const found = Object.keys(encodings).find((key) => { |
| 22 | if (key.toLowerCase() === charset) { |
| 23 | return true; |
| 24 | } |
| 25 | |
| 26 | const alias = encodings[key].aliases.find( |
| 27 | (alias) => alias.toLowerCase() === charset, |
| 28 | ); |
| 29 | if (alias) { |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | return false; |
| 34 | }); |
| 35 | |
| 36 | if (found) { |
| 37 | return encodings[found]; |
| 38 | } |
| 39 | |
| 40 | return encodings["UTF-8"]; |
| 41 | } |
| 42 | |
| 43 | function detectBOM(bytes) { |
| 44 | if ( |
no outgoing calls
no test coverage detected