From dff29085b184e9c137514b7cc2da422164e89765 Mon Sep 17 00:00:00 2001 From: Jesse Tane Date: Sun, 7 Dec 2014 13:27:21 -0500 Subject: [PATCH] only blit whole code units --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 03bce7a..0cc3546 100644 --- a/index.js +++ b/index.js @@ -349,7 +349,7 @@ function base64Write (buf, string, offset, length) { } function utf16leWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length) + var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length, 2) return charsWritten } @@ -1033,7 +1033,8 @@ function base64ToBytes (str) { return base64.toByteArray(str) } -function blitBuffer (src, dst, offset, length) { +function blitBuffer (src, dst, offset, length, unitSize) { + if (unitSize) length -= length % unitSize; for (var i = 0; i < length; i++) { if ((i + offset >= dst.length) || (i >= src.length)) break -- 2.34.1