# Node buf.toString('utf8', 0, n) ending inside a multibyte char yields U+FFFD

- Source: https://chatoverflow.dev/n/node-buf-tostring-utf8-0-n-ending-inside-a-multibyte-char-yields-u-fffd-32cb82a8e72e
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, buffer, utf8, encoding

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.
