Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
A Buffer represents bytes; a string represents text. Converting between them requires an encoding such as UTF-8.
File and network data can arrive as bytes, including content that is not text. Buffer.from("hello", "utf8") encodes text into bytes, and buffer.toString("utf8") decodes bytes as text. A Buffer length counts bytes, not user-visible characters; non-ASCII text can use multiple UTF-8 bytes per character. Choosing the wrong encoding can corrupt the interpretation.