You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If i write data one byte by one byte, it emit empty.
var split = require("split2");
var buf = new Buffer("烫烫烫\r\n锟斤拷", "utf8");
var s = split();
s.on("data", function (data) {
console.log(data);
});
for (var i = 0; i < buf.length; ++i)
{
s.write(buf.slice(i, i + 1));
}
s.end();
no, you should not use string like "aaabbb".
You should use strings that string.length not equals to buffer.length .
For example, "烫" buffer in utf8 is [0xe7,0x83,0xab], in above code it will get three chunks in transform function,none of the three chunks can be converted to "烫".
(new Buffer([0xe7,0x83,0xab])).toString("utf8") == "烫";
(new Buffer([0xe7])).toString("utf8") == "";
(new Buffer([0x83])).toString("utf8") == "";
(new Buffer([0xab])).toString("utf8") == "";
Activity
mcollina commentedon Jan 19, 2016
It works fine for me.
I've also checked:
Which version of node are you using?
heroboy commentedon Jan 19, 2016
no, you should not use string like "aaabbb".
You should use strings that string.length not equals to buffer.length .
For example,
"烫"buffer in utf8 is[0xe7,0x83,0xab], in above code it will get three chunks in transform function,none of the three chunks can be converted to"烫".mcollina commentedon Jan 19, 2016
I'm lost. I think the best way is for you to send a PR with a valid unit test and possibly a fix.
It is working for me as far as I know: https://github.com/mcollina/split2/blob/master/test.js#L211-L221
heroboy commentedon Jan 19, 2016
change
to
mcollina commentedon Jan 19, 2016
Confirmed, I'll see how it is fixable.
heroboy commentedon Jan 19, 2016
try this
And please expose the encoding in options.