This is small code snippet from my side( I learner, don't know more about js ).
So please add it in upcoming version release of RMS ( I am personally tested, it working well )
Q ) What it does ?
Ans: API Output will be gives in the form of string or bytes, based on ascii value compare it gives output
Bytes2String
function bin2String(array){ var result = ""; for(var i = 0; i < array.length; ++i){ result+= (String.fromCharCode(array[i])); } return result; }
Ascii check from string
function isAsciiOnly(str) { for (var i = 0; i < str.length; i++) if (str.charCodeAt(i) > 127) return false; return true; }
Giving output based on ascii value (string or bytes)
function printType(str){ var check = bin2String(str); if(isAsciiOnly(check) == true){ return bin2String(str); } else { return str; } }
API Monitor (Now output print type decides based on ascii value compare from string, if ascii is false then output in bytes, otherwise it's in string )
if (callback) { var calledFrom = Exception.$new().getStackTrace().toString().split(',')[1]; var to_print = { category: category, class: clazz, method: method, args: args ? printType(args[0]) : "N/A", returnValue: retval ? printType(retval) : "N/A", calledFrom: calledFrom }; retval = callback(retval, to_print); }
This is small code snippet from my side( I learner, don't know more about js ). So please add it in upcoming version release of RMS ( I am personally tested, it working well )
Q ) What it does ? Ans: API Output will be gives in the form of string or bytes, based on ascii value compare it gives output
Bytes2String
function bin2String(array){ var result = ""; for(var i = 0; i < array.length; ++i){ result+= (String.fromCharCode(array[i])); } return result; }
Ascii check from string
function isAsciiOnly(str) { for (var i = 0; i < str.length; i++) if (str.charCodeAt(i) > 127) return false; return true; }
Giving output based on ascii value (string or bytes)
function printType(str){ var check = bin2String(str); if(isAsciiOnly(check) == true){ return bin2String(str); } else { return str; } }
API Monitor (Now output print type decides based on ascii value compare from string, if ascii is false then output in bytes, otherwise it's in string )
if (callback) { var calledFrom = Exception.$new().getStackTrace().toString().split(',')[1]; var to_print = { category: category, class: clazz, method: method, args: args ? printType(args[0]) : "N/A", returnValue: retval ? printType(retval) : "N/A", calledFrom: calledFrom }; retval = callback(retval, to_print); }