From acc2caa00a9fa10c9a7ea571deed261cf1ecf90a Mon Sep 17 00:00:00 2001 From: Jesse Tane Date: Mon, 15 Dec 2014 19:16:40 -0500 Subject: [PATCH] strip high bit when ascii slicing --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) { -- 2.34.1