(buffer: Buffer)
| 154 | * @return The detected encoding as a lowercase string, or null if detection fails. |
| 155 | */ |
| 156 | export function detectEncodingFromBuffer(buffer: Buffer): string | null { |
| 157 | try { |
| 158 | const detected = chardetDetect(buffer); |
| 159 | if (detected && typeof detected === 'string') { |
| 160 | return detected.toLowerCase(); |
| 161 | } |
| 162 | } catch (error) { |
| 163 | console.warn('Failed to detect encoding with chardet:', error); |
| 164 | } |
| 165 | |
| 166 | return null; |
| 167 | } |
no outgoing calls
no test coverage detected