thinker3
thinker3

Reputation: 13291

How to convert hex numbers to byte string?

> str = '\xae\xee'
'®î'

How to convert [0xae, 0xee] to '®î'?

Upvotes: 0

Views: 127

Answers (1)

Nick Parsons
Nick Parsons

Reputation: 50639

You can use String.fromCharCode() to convert the hex values to their string representation with .map() and .join() to form a string:

const hex = [0xae, 0xee];
const res = hex.map(s => String.fromCharCode(s)).join('');
console.log(res);

Upvotes: 3

Related Questions