(input: string)
| 2 | // and should only be utf8 characters so this fixes |
| 3 | // incorrectly encoded values |
| 4 | export function fixMojibake(input: string): string { |
| 5 | // Convert each character's char code to a byte |
| 6 | const bytes = new Uint8Array(input.length) |
| 7 | for (let i = 0; i < input.length; i++) { |
| 8 | bytes[i] = input.charCodeAt(i) |
| 9 | } |
| 10 | |
| 11 | // Decode the bytes as proper UTF-8 |
| 12 | const decoder = new TextDecoder('utf-8') |
| 13 | return decoder.decode(bytes) |
| 14 | } |
no test coverage detected