vivianaranha
vivianaranha

Reputation: 2781

Javascript String Output - Something to do with its type

I have a variable - I know its a special byte array or something similar - i might be wrong.

The question is I am expecting to print this on console

\xddSM\x8f\xda0\x10\xfd+\xab\xd9kH\xe2\xb0\x85\x92S\x17zi\xb5\xaaV\xdam/\x15\x07\xe3\x0c\xc4\x95?\x90\xed\x04\xe8*\xff\xbdc\x03\xdbVZ\xb8\xf5R

but all i see is this

�SM��0�+��kHⰅ�Szi��V�m/�ĕ?���*��c�VZ��R    

I cant post the code for it - But I guess some of you might have already got the idea

Upvotes: 0

Views: 46

Answers (1)

Dan Mullin
Dan Mullin

Reputation: 4415

You can use the escape function like this to print the string to the console or insert it into the HTML.

var x = escape("\xddSM\x8f\xda0\x10\xfd+\xab\xd9kH\xe2\xb0\x85\x92S\x17zi\xb5\xaaV\xdam/\x15\x07\xe3\x0c\xc4\x95?\x90\xed\x04\xe8*\xff\xbdc\x03\xdbVZ\xb8\xf5R").replace(/(%)/g, "\\x").toLowerCase();

document.getElementById("target").innerHTML = x;
<div id="target"></div>

Upvotes: 1

Related Questions