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.】