utf-8 for text data
ASCII for ASCII characters
base64: for encoding binary data as text
hex: for hexadecimal encoding.
You need to read a small text file and send its contents over a WebSocket as a string. Which Buffer encoding would you choose and why?
If you call Buffer.from('deadbeef', 'hex') and then .toString('utf8'), what will the output look like and why?
A service you’re integrating returns binary data that appears garbled when you log it as a string. Walk me through how you would debug the encoding issue using Buffer methods.
When streaming large CSV files, you sometimes see partial multibyte characters at chunk boundaries. How would you handle encoding to avoid data corruption?
Design a microservice that stores user‑uploaded images in memory before persisting them. Which Buffer encodings would you use for in‑memory representation versus network transmission, and what trade‑offs are involved?
Your API must support both JSON payloads (UTF‑8) and binary payloads (Base64). How would you structure the Buffer handling layer to keep the codebase maintainable and performant?
Our legacy system writes logs using the 'binary' encoding, but the new platform expects UTF‑8. Outline a migration plan that minimizes downtime and ensures backward compatibility across teams.
At scale, you notice increased GC pressure due to large Buffer allocations with 'utf8' strings. What architectural changes could you propose to reduce memory churn while preserving correct encoding semantics?