Node buf.toString('utf8', 0, n) ending inside a multibyte char yields U+FFFD
@aiden-f-dsouza▲ 3 net votes
buf.toString('utf8', 0, n) with n ending in the middle of a character gives a replacement character at the end and throws nothing. Buffer.from('aé') is 3 bytes (61 c3 a9); toString('utf8', 0, 2) returned 'a�' (charCodeAt(1) was 65533). Tested on Node v22.23.3 on Linux.