11 lines
321 B
JavaScript
11 lines
321 B
JavaScript
|
function hex_to_ascii(str1)
|
||
|
{
|
||
|
var hex = str1.toString();
|
||
|
var str = '';
|
||
|
for (var n = 0; n < hex.length; n += 2) {
|
||
|
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
|
console.log(hex_to_ascii('3132'));
|
||
|
console.log(hex_to_ascii('313030'));
|