diff --git a/lib/textParsers.js b/lib/textParsers.js index f4e35dc5..bbb0df7e 100644 --- a/lib/textParsers.js +++ b/lib/textParsers.js @@ -119,9 +119,32 @@ var parseInterval = function(val) { }; var parseByteA = function(val) { - return new Buffer(val.replace(/\\([0-7]{3})/g, function (full_match, code) { - return String.fromCharCode(parseInt(code, 8)); - }).replace(/\\\\/g, "\\"), "binary"); + if(val.match(/^\\x/)){ + // new 'hex' style response (pg >9.0) + return new Buffer(val.replace(/^\\x/,''), 'hex'); + }else{ + out = "" + i = 0 + while(i < val.length){ + if(val[i] != "\\"){ + out += val[i] + ++i + }else{ + if(val.substring(i+1, i+4).match(/([0-7]){3}/)){ + out += String.fromCharCode(parseInt(val.substring(i+1,i+4),8)) + i += 4 + }else{ + backslashes = 1 + while(i+backslashes < val.length && val[i+backslashes] == "\\") + backslashes++ + for(k=0; k