-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
var s0 = 'тест ';
s0 += new Array(1031913 + 1 - s0.length).join('Z');
var s1 = new Buffer(s0, 'ucs2').toString('ucs2');
var s2 = new Buffer(s1, 'utf-8').toString('utf-8');
console.log(s0 === s2);
console.log(s0.substr(0, 200));
console.log(s2.substr(0, 200));
This works under node 0.10 (s0
equals to s2
, the example logs 2 equal strings), but breaks in iojs 1.2.0 and 1.4.2 (s0
is not equal to s2
, the second logged string is not correct).
When broken, s2.substr(0, 200)
somewhy equals to new Buffer(s0, 'ucs2').toString('utf-8').substr(0, 200)
.
1031913 is the critical length, non-latin strings with length greater or equal to 1031913 trigger the bug, strings with length equal or less than 1031912 do not trigger the bug.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.