From: Jesse Tane Date: Tue, 16 Dec 2014 00:16:40 +0000 (-0500) Subject: strip high bit when ascii slicing X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=acc2caa00a9fa10c9a7ea571deed261cf1ecf90a;p=buffer.git strip high bit when ascii slicing --- diff --git a/index.js b/index.js index 27aae14..38b20ba 100644 --- a/index.js +++ b/index.js @@ -462,13 +462,19 @@ function asciiSlice (buf, start, end) { end = Math.min(buf.length, end) for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) + ret += String.fromCharCode(buf[i] & 0x7F) } return ret } function binarySlice (buf, start, end) { - return asciiSlice(buf, start, end) + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret } function hexSlice (buf, start, end) {