import { StringDecoder } from 'node:string_decoder'; const bytes = Buffer.from('kit-é', 'utf8'); const decoder = new StringDecoder('utf8'); const text = decoder.write(bytes.subarray(0, bytes.length - 1)) + decoder.end(bytes.subarray(bytes.length - 1)); console.log(bytes.length); console.log(text); console.log(Buffer.from('kit').toString('hex'));