调用 readable.setEncoding() 后 highWaterMark 不一致


¥highWaterMark discrepancy after calling readable.setEncoding()

使用 readable.setEncoding() 将改变 highWaterMark 在非对象模式下的运行方式。

¥The use of readable.setEncoding() will change the behavior of how the highWaterMark operates in non-object mode.

通常,当前缓冲区的大小是根据 highWaterMark 以字节为单位测量的。但是,在调用 setEncoding() 之后,比较函数将开始测量缓冲区的字符大小。

¥Typically, the size of the current buffer is measured against the highWaterMark in bytes. However, after setEncoding() is called, the comparison function will begin to measure the buffer's size in characters.

在 latin1 或 ascii 的常见情况下,这不是问题。但建议在处理可能包含多字节字符的字符串时注意这种行为。

¥This is not a problem in common cases with latin1 or ascii. But it is advised to be mindful about this behavior when working with strings that could contain multi-byte characters.