Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: add test for unaligned ucs2 buffer write
Between #3410 and #7645, bytes were swapped twice on bigendian
platforms if buffer was not two-byte aligned. See comment in #7645.
  • Loading branch information
zbjornson committed Sep 30, 2016
commit 2b69933796a1b5f1c59cd206b75e3616624fea2c
6 changes: 6 additions & 0 deletions test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ assert.strictEqual('<Buffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
assert.strictEqual(b.toString(encoding), 'あいうえお');
});

['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach((encoding) => {
const b = Buffer.allocUnsafe(11);
b.write('あいうえお', 1, encoding);
assert.strictEqual(b.toString(encoding, 1), 'あいうえお');
});

{
// latin1 encoding should write only one byte per character.
const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]);
Expand Down