* @param {BufferEncoding} encoding * @returns {this}
(encoding)
| 324 | * @returns {this} |
| 325 | */ |
| 326 | setEncoding (encoding) { |
| 327 | if (Buffer.isEncoding(encoding)) { |
| 328 | // Delegate to Node.js Readable.setEncoding() which initializes a |
| 329 | // StringDecoder and re-encodes already-buffered chunks. This properly |
| 330 | // handles multi-byte sequences split at chunk boundaries for the |
| 331 | // for-await / on('data') paths. Without this, Node.js uses |
| 332 | // buf.toString(encoding) on each chunk, producing U+FFFD for split chars. |
| 333 | // |
| 334 | // The consume path (body.text(), body.json(), ...) copes with the |
| 335 | // decoded strings this leaves in state.buffer, see consumeStart(). |
| 336 | super.setEncoding(encoding) |
| 337 | } |
| 338 | return this |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | /** |
no outgoing calls
no test coverage detected