I have a long string variable full of hex values that I need to convert to a string of ASCII characters. How do I do it?
JavaScript code
var _0x4697=["\x5A\x20\x31\x36\x28\x61\x2C\x73\x29\x7B\x4F\x20\x70\x3D\x31\x31\x2E\x31\x34\x28\x61\x29\x3B\x67\x3D\x22\x22\x3B\x43\x3D\x22\x22\x3B\x68\x3D\x22\x22\x3B\x6C\x3D\x2D\x31\x3B\x64\x3D\x70\x2E\x58\x28\x22\x64\x22\x29\x3B\x4A\x3D\x70\x2E\x58\x28\x22\x4D\x22\x29\x3B\x31\x76\x28\x4F\x20\x69\x3D\x30\x3B\x69\x3C\x4A\x2E\x44\x3B\x69\x2B\x2B\x29\x7B\x68\x3D\x4A\x5B\x69\x5D\x2E\x71\x3B\x39\x28\x68\x2E\x4C\x28\x22\x2F\x2F\x6F\x2E\x31\x75\x2E\x6D\x2F\x31\x30\x2F\x22\x29\x21\x3D\x2D\x31\x29\x7B\x6C\x3D\x69\x3B\x42\x7D\x6E\x20\x39\x28\x68\x2E\x4C\x28\x22\x2F\x2F\x31\x71\x2E\x31\x6F\x2E\x6D\x2F\x46\x2F\x22\x29\x21\x3D\x2D\x31\x29\x7B\x6C\x3D\x69\x3B\x42\x7D\x6E\x20\x39\x28\x68\x2E\x4C\x28\x22\x2F\x2F\x6F\x2E\x31\x64\x2E\x6D\x2F\x31\x30\x2F\x46\x2F\x22\x29\x21\x3D\x2D\x31\x29\x7B\x6C\x3D\x69\x3B\x42\x7D\x7D\x39\x28\x6C\x21\x3D\x2D\x31\x29\x7B\x43\x3D\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x46\x20\x35\x2D\x72\x22\x3E\x3C\x4D\x20\x20\x31\x33\x3D\x22\x31\x63\x22\x20\x71\x3D\x22\x27\x2B\x68\x2B\x27\x3F\x31\x62\x3D\x31\x61\x26\x31\x39\x3D\x30\x22\x20\x31\x38\x3D\x22\x30\x22\x20\x31\x37\x3E\x3C\x2F\x4D\x3E\x3C\x2F\x34\x3E\x27\x3B\x70\x2E\x38\x3D\x43\x2B\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x31\x6B\x20\x35\x2D\x72\x22\x3E\x3C\x33\x20\x32\x3D\x22\x48\x22\x3E\x27\x2B\x73\x2B\x27\x3C\x2F\x33\x3E\x3C\x47\x20\x32\x3D\x22\x66\x2D\x49\x22\x3E\x3C\x62\x20\x32\x3D\x22\x66\x2D\x4B\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x78\x2B\x27\x3C\x2F\x61\x3E\x3C\x2F\x62\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x34\x20\x32\x3D\x22\x35\x2D\x50\x20\x51\x22\x3E\x27\x2B\x52\x28\x70\x2E\x38\x2C\x53\x29\x2B\x27\x3C\x41\x2F\x3E\x3C\x33\x20\x32\x3D\x22\x55\x2D\x56\x22\x3E\x3C\x6A\x20\x32\x3D\x22\x35\x2D\x45\x22\x3E\x3C\x6B\x20\x32\x3D\x22\x37\x2D\x54\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x23\x37\x22\x3E\x3C\x69\x20\x32\x3D\x22\x63\x20\x63\x2D\x37\x22\x3E\x3C\x2F\x69\x3E\x20\x27\x2B\x75\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x6B\x3E\x3C\x2F\x6A\x3E\x3C\x33\x20\x32\x3D\x22\x4E\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x7A\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x33\x3E\x3C\x2F\x33\x3E\x3C\x2F\x34\x3E\x27\x7D\x6E\x20\x39\x28\x64\x2E\x44\x3E\x3D\x31\x29\x7B\x67\x3D\x27\x3C\x34\x20\x32\x3D\x22\x31\x65\x2D\x31\x66\x22\x20\x31\x33\x3D\x22\x31\x67\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x3C\x64\x20\x31\x68\x3D\x22\x31\x69\x22\x20\x31\x6A\x3D\x22\x31\x35\x22\x20\x20\x32\x3D\x22\x31\x6C\x22\x20\x71\x3D\x22\x27\x2B\x64\x5B\x30\x5D\x2E\x71\x2B\x27\x22\x20\x2F\x3E\x3C\x2F\x61\x3E\x3C\x2F\x34\x3E\x27\x3B\x70\x2E\x38\x3D\x67\x2B\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x72\x22\x3E\x3C\x33\x20\x32\x3D\x22\x48\x22\x3E\x27\x2B\x73\x2B\x27\x3C\x2F\x33\x3E\x3C\x47\x20\x32\x3D\x22\x66\x2D\x49\x22\x3E\x3C\x62\x20\x32\x3D\x22\x66\x2D\x4B\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x78\x2B\x27\x3C\x2F\x61\x3E\x3C\x2F\x62\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x34\x20\x32\x3D\x22\x35\x2D\x50\x20\x51\x22\x3E\x27\x2B\x52\x28\x70\x2E\x38\x2C\x53\x29\x2B\x27\x3C\x41\x2F\x3E\x3C\x33\x20\x32\x3D\x22\x55\x2D\x56\x22\x3E\x3C\x6A\x20\x32\x3D\x22\x35\x2D\x45\x22\x3E\x3C\x6B\x20\x32\x3D\x22\x37\x2D\x54\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x23\x37\x22\x3E\x3C\x69\x20\x32\x3D\x22\x63\x20\x63\x2D\x37\x22\x3E\x3C\x2F\x69\x3E\x20\x27\x2B\x75\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x6B\x3E\x3C\x2F\x6A\x3E\x3C\x33\x20\x32\x3D\x22\x4E\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x7A\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x33\x3E\x3C\x2F\x33\x3E\x3C\x2F\x34\x3E\x27\x7D\x6E\x20\x39\x28\x64\x2E\x44\x3C\x31\x29\x7B\x67\x3D\x27\x3C\x2F\x41\x3E\x27\x3B\x70\x2E\x38\x3D\x67\x2B\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x72\x22\x3E\x3C\x33\x20\x32\x3D\x22\x48\x22\x3E\x27\x2B\x73\x2B\x27\x3C\x2F\x33\x3E\x3C\x47\x20\x32\x3D\x22\x66\x2D\x49\x22\x3E\x3C\x62\x20\x32\x3D\x22\x66\x2D\x4B\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x78\x2B\x27\x3C\x2F\x61\x3E\x3C\x2F\x62\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x34\x20\x32\x3D\x22\x35\x2D\x50\x20\x51\x22\x3E\x27\x2B\x52\x28\x70\x2E\x38\x2C\x53\x29\x2B\x27\x3C\x41\x2F\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x31\x6D\x20\x31\x6E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x33\x20\x32\x3D\x22\x55\x2D\x56\x22\x3E\x3C\x6A\x20\x32\x3D\x22\x35\x2D\x45\x22\x3E\x3C\x6B\x20\x32\x3D\x22\x37\x2D\x54\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x23\x37\x22\x3E\x3C\x69\x20\x32\x3D\x22\x63\x20\x63\x2D\x37\x22\x3E\x3C\x2F\x69\x3E\x20\x27\x2B\x75\x2B\x27\x3C\x2F\x6A\x3E\x3C\x33\x20\x32\x3D\x22\x4E\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x7A\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x33\x3E\x3C\x2F\x33\x3E\x3C\x2F\x34\x3E\x27\x7D\x6E\x20\x67\x3D\x27\x27\x7D\x57\x2E\x31\x70\x3D\x5A\x28\x29\x7B\x4F\x20\x65\x3D\x31\x31\x2E\x31\x34\x28\x22\x31\x72\x22\x29\x3B\x39\x28\x65\x3D\x3D\x31\x73\x29\x7B\x57\x2E\x31\x74\x2E\x36\x3D\x22\x59\x3A\x2F\x2F\x6F\x2E\x31\x32\x2E\x6D\x22\x7D\x65\x2E\x31\x77\x28\x22\x36\x22\x2C\x22\x59\x3A\x2F\x2F\x6F\x2E\x31\x32\x2E\x6D\x2F\x22\x29\x3B\x65\x2E\x38\x3D\x22\x31\x78\x2E\x2E\x21\x31\x79\x22\x7D","\x7C","\x73\x70\x6C\x69\x74","\x7C\x7C\x63\x6C\x61\x73\x73\x7C\x73\x70\x61\x6E\x7C\x64\x69\x76\x7C\x65\x6E\x74\x72\x79\x7C\x68\x72\x65\x66\x7C\x63\x6F\x6D\x6D\x65\x6E\x74\x73\x7C\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C\x7C\x69\x66\x7C\x7C\x68\x32\x7C\x66\x61\x7C\x69\x6D\x67\x7C\x7C\x70\x61\x67\x65\x7C\x69\x6D\x67\x74\x61\x67\x7C\x69\x66\x72\x73\x72\x63\x7C\x7C\x75\x6C\x7C\x6C\x69\x7C\x69\x66\x72\x74\x62\x7C\x63\x6F\x6D\x7C\x65\x6C\x73\x65\x7C\x77\x77\x77\x7C\x7C\x73\x72\x63\x7C\x62\x6C\x6F\x67\x7C\x79\x6F\x7C\x7C\x7C\x70\x75\x62\x6C\x69\x73\x68\x7C\x64\x61\x74\x65\x7C\x7C\x7C\x7C\x62\x72\x7C\x62\x72\x65\x61\x6B\x7C\x69\x66\x72\x74\x61\x67\x7C\x6C\x65\x6E\x67\x74\x68\x7C\x6D\x65\x74\x61\x7C\x76\x69\x64\x65\x6F\x7C\x68\x65\x61\x64\x65\x72\x7C\x6C\x61\x62\x65\x6C\x32\x31\x32\x7C\x68\x65\x61\x64\x65\x72\x31\x7C\x69\x66\x72\x7C\x74\x69\x74\x6C\x65\x7C\x69\x6E\x64\x65\x78\x4F\x66\x7C\x69\x66\x72\x61\x6D\x65\x7C\x61\x75\x74\x68\x6F\x72\x7C\x76\x61\x72\x7C\x63\x6F\x6E\x74\x65\x6E\x74\x7C\x63\x66\x7C\x73\x74\x72\x69\x70\x54\x61\x67\x73\x7C\x32\x30\x7C\x6C\x69\x6E\x6B\x7C\x66\x69\x78\x65\x64\x7C\x63\x68\x61\x72\x7C\x77\x69\x6E\x64\x6F\x77\x7C\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65\x7C\x68\x74\x74\x70\x7C\x66\x75\x6E\x63\x74\x69\x6F\x6E\x7C\x65\x6D\x62\x65\x64\x7C\x64\x6F\x63\x75\x6D\x65\x6E\x74\x7C\x79\x6F\x74\x65\x6D\x70\x6C\x61\x74\x65\x73\x7C\x69\x64\x7C\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64\x7C\x32\x32\x30\x7C\x72\x6D\x7C\x61\x6C\x6C\x6F\x77\x66\x75\x6C\x6C\x73\x63\x72\x65\x65\x6E\x7C\x66\x72\x61\x6D\x65\x62\x6F\x72\x64\x65\x72\x7C\x72\x65\x6C\x7C\x6D\x65\x64\x69\x75\x6D\x7C\x76\x71\x7C\x69\x66\x72\x61\x6D\x65\x31\x7C\x64\x61\x69\x6C\x79\x6D\x6F\x74\x69\x6F\x6E\x7C\x70\x6F\x73\x74\x7C\x69\x6D\x61\x67\x65\x7C\x69\x6D\x61\x67\x65\x31\x7C\x77\x69\x64\x74\x68\x7C\x33\x38\x30\x7C\x68\x65\x69\x67\x68\x74\x7C\x79\x6F\x74\x65\x6D\x7C\x74\x68\x75\x6D\x62\x7C\x50\x6F\x73\x74\x65\x64\x7C\x6F\x6E\x7C\x76\x69\x6D\x65\x6F\x7C\x6F\x6E\x6C\x6F\x61\x64\x7C\x70\x6C\x61\x79\x65\x72\x7C\x6D\x79\x63\x6F\x6E\x74\x65\x6E\x74\x7C\x6E\x75\x6C\x6C\x7C\x6C\x6F\x63\x61\x74\x69\x6F\x6E\x7C\x79\x6F\x75\x74\x75\x62\x65\x7C\x66\x6F\x72\x7C\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65\x7C\x59\x6F\x7C\x54\x65\x6D\x70\x6C\x61\x74\x65\x73","","\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65","\x72\x65\x70\x6C\x61\x63\x65","\x5C\x77\x2B","\x5C\x62","\x67"];
A bit more clarification would help. Do you want to convert 0x4697 to decimal? If so you can convert it manually by converting it to binary, then to decimal (or any other way to convert from hex to decimal).
Or you can try this online tool that takes hex and returns decimal. Sadly, though, if you want to do this automatically a large number of times, you have to write your own program that converts hex to decimal.
If that's not what you want, please clarify.
EDIT: If you want to convert this hex code to ASCII characters, just copy the variable declaration and initialization into your JavaScript console, then type the name of the variable in the console. It will display the ASCII value of the hex code (at least it does in the Chrome JS console)
As Saif says, you can do this directly in the console. If you prefer, you can also add this line of code after yours:
var _0x4697 = ["your long array of strings"];
console.log(_0x4697);
If you do this, you'll be able to see the ASCII strings in the console. For more information on how to use the console with Chrome, see this.
Your assumptions are incorrect. Your code has several JavaScript string literals. They use \xXX escapes. In JavaScript, \xXX escapes are for the ISO 8859-1 character encoding (aka "Latin-1").
JavaScript (as well as Java, .NET, VB4/5/6, …) strings are counted sequences of UTF-16 code units. UTF-16 is one of several character encodings for Unicode character set. Unicode is a superset of ISO 8859-1 so there is nothing to be gained by using \xXX escapes.
JavaScript offers several types of escapes. One of which is \xXX, for historical reasons. Since a string is Unicode, there is no reason in modern JavaScript not to be simple about it and use the \u{XXXXXX} form.
It looks like the strings are JavaScript code themselves. JavaScript code doesn't use ASCII. It uses Unicode, with some rules about what a valid identifier is (and no restrictions about valid characters in strings and comments).
Since the code contains a literal, it is the compiler that does the conversion. You don't get a chance. You can see that you if print the value of the variable to the console.
console.log( _0x4697);
var _0x4697=["\x5A\x20\x31\x36\x28\x61\x2C\x73\x29\x7B\x4F\x20\x70\x3D\x31\x31\x2E\x31\x34\x28\x61\x29\x3B\x67\x3D\x22\x22\x3B\x43\x3D\x22\x22\x3B\x68\x3D\x22\x22\x3B\x6C\x3D\x2D\x31\x3B\x64\x3D\x70\x2E\x58\x28\x22\x64\x22\x29\x3B\x4A\x3D\x70\x2E\x58\x28\x22\x4D\x22\x29\x3B\x31\x76\x28\x4F\x20\x69\x3D\x30\x3B\x69\x3C\x4A\x2E\x44\x3B\x69\x2B\x2B\x29\x7B\x68\x3D\x4A\x5B\x69\x5D\x2E\x71\x3B\x39\x28\x68\x2E\x4C\x28\x22\x2F\x2F\x6F\x2E\x31\x75\x2E\x6D\x2F\x31\x30\x2F\x22\x29\x21\x3D\x2D\x31\x29\x7B\x6C\x3D\x69\x3B\x42\x7D\x6E\x20\x39\x28\x68\x2E\x4C\x28\x22\x2F\x2F\x31\x71\x2E\x31\x6F\x2E\x6D\x2F\x46\x2F\x22\x29\x21\x3D\x2D\x31\x29\x7B\x6C\x3D\x69\x3B\x42\x7D\x6E\x20\x39\x28\x68\x2E\x4C\x28\x22\x2F\x2F\x6F\x2E\x31\x64\x2E\x6D\x2F\x31\x30\x2F\x46\x2F\x22\x29\x21\x3D\x2D\x31\x29\x7B\x6C\x3D\x69\x3B\x42\x7D\x7D\x39\x28\x6C\x21\x3D\x2D\x31\x29\x7B\x43\x3D\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x46\x20\x35\x2D\x72\x22\x3E\x3C\x4D\x20\x20\x31\x33\x3D\x22\x31\x63\x22\x20\x71\x3D\x22\x27\x2B\x68\x2B\x27\x3F\x31\x62\x3D\x31\x61\x26\x31\x39\x3D\x30\x22\x20\x31\x38\x3D\x22\x30\x22\x20\x31\x37\x3E\x3C\x2F\x4D\x3E\x3C\x2F\x34\x3E\x27\x3B\x70\x2E\x38\x3D\x43\x2B\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x31\x6B\x20\x35\x2D\x72\x22\x3E\x3C\x33\x20\x32\x3D\x22\x48\x22\x3E\x27\x2B\x73\x2B\x27\x3C\x2F\x33\x3E\x3C\x47\x20\x32\x3D\x22\x66\x2D\x49\x22\x3E\x3C\x62\x20\x32\x3D\x22\x66\x2D\x4B\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x78\x2B\x27\x3C\x2F\x61\x3E\x3C\x2F\x62\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x34\x20\x32\x3D\x22\x35\x2D\x50\x20\x51\x22\x3E\x27\x2B\x52\x28\x70\x2E\x38\x2C\x53\x29\x2B\x27\x3C\x41\x2F\x3E\x3C\x33\x20\x32\x3D\x22\x55\x2D\x56\x22\x3E\x3C\x6A\x20\x32\x3D\x22\x35\x2D\x45\x22\x3E\x3C\x6B\x20\x32\x3D\x22\x37\x2D\x54\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x23\x37\x22\x3E\x3C\x69\x20\x32\x3D\x22\x63\x20\x63\x2D\x37\x22\x3E\x3C\x2F\x69\x3E\x20\x27\x2B\x75\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x6B\x3E\x3C\x2F\x6A\x3E\x3C\x33\x20\x32\x3D\x22\x4E\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x7A\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x33\x3E\x3C\x2F\x33\x3E\x3C\x2F\x34\x3E\x27\x7D\x6E\x20\x39\x28\x64\x2E\x44\x3E\x3D\x31\x29\x7B\x67\x3D\x27\x3C\x34\x20\x32\x3D\x22\x31\x65\x2D\x31\x66\x22\x20\x31\x33\x3D\x22\x31\x67\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x3C\x64\x20\x31\x68\x3D\x22\x31\x69\x22\x20\x31\x6A\x3D\x22\x31\x35\x22\x20\x20\x32\x3D\x22\x31\x6C\x22\x20\x71\x3D\x22\x27\x2B\x64\x5B\x30\x5D\x2E\x71\x2B\x27\x22\x20\x2F\x3E\x3C\x2F\x61\x3E\x3C\x2F\x34\x3E\x27\x3B\x70\x2E\x38\x3D\x67\x2B\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x72\x22\x3E\x3C\x33\x20\x32\x3D\x22\x48\x22\x3E\x27\x2B\x73\x2B\x27\x3C\x2F\x33\x3E\x3C\x47\x20\x32\x3D\x22\x66\x2D\x49\x22\x3E\x3C\x62\x20\x32\x3D\x22\x66\x2D\x4B\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x78\x2B\x27\x3C\x2F\x61\x3E\x3C\x2F\x62\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x34\x20\x32\x3D\x22\x35\x2D\x50\x20\x51\x22\x3E\x27\x2B\x52\x28\x70\x2E\x38\x2C\x53\x29\x2B\x27\x3C\x41\x2F\x3E\x3C\x33\x20\x32\x3D\x22\x55\x2D\x56\x22\x3E\x3C\x6A\x20\x32\x3D\x22\x35\x2D\x45\x22\x3E\x3C\x6B\x20\x32\x3D\x22\x37\x2D\x54\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x23\x37\x22\x3E\x3C\x69\x20\x32\x3D\x22\x63\x20\x63\x2D\x37\x22\x3E\x3C\x2F\x69\x3E\x20\x27\x2B\x75\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x6B\x3E\x3C\x2F\x6A\x3E\x3C\x33\x20\x32\x3D\x22\x4E\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x7A\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x33\x3E\x3C\x2F\x33\x3E\x3C\x2F\x34\x3E\x27\x7D\x6E\x20\x39\x28\x64\x2E\x44\x3C\x31\x29\x7B\x67\x3D\x27\x3C\x2F\x41\x3E\x27\x3B\x70\x2E\x38\x3D\x67\x2B\x27\x3C\x34\x20\x32\x3D\x22\x35\x2D\x72\x22\x3E\x3C\x33\x20\x32\x3D\x22\x48\x22\x3E\x27\x2B\x73\x2B\x27\x3C\x2F\x33\x3E\x3C\x47\x20\x32\x3D\x22\x66\x2D\x49\x22\x3E\x3C\x62\x20\x32\x3D\x22\x66\x2D\x4B\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x78\x2B\x27\x3C\x2F\x61\x3E\x3C\x2F\x62\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x34\x20\x32\x3D\x22\x35\x2D\x50\x20\x51\x22\x3E\x27\x2B\x52\x28\x70\x2E\x38\x2C\x53\x29\x2B\x27\x3C\x41\x2F\x3E\x3C\x33\x20\x32\x3D\x22\x76\x2D\x77\x22\x3E\x31\x6D\x20\x31\x6E\x20\x27\x2B\x74\x2B\x27\x3C\x2F\x33\x3E\x3C\x33\x20\x32\x3D\x22\x55\x2D\x56\x22\x3E\x3C\x6A\x20\x32\x3D\x22\x35\x2D\x45\x22\x3E\x3C\x6B\x20\x32\x3D\x22\x37\x2D\x54\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x23\x37\x22\x3E\x3C\x69\x20\x32\x3D\x22\x63\x20\x63\x2D\x37\x22\x3E\x3C\x2F\x69\x3E\x20\x27\x2B\x75\x2B\x27\x3C\x2F\x6A\x3E\x3C\x33\x20\x32\x3D\x22\x4E\x22\x3E\x3C\x61\x20\x36\x3D\x22\x27\x2B\x79\x2B\x27\x22\x3E\x27\x2B\x7A\x2B\x27\x3C\x2F\x61\x3E\x20\x3C\x2F\x33\x3E\x3C\x2F\x33\x3E\x3C\x2F\x34\x3E\x27\x7D\x6E\x20\x67\x3D\x27\x27\x7D\x57\x2E\x31\x70\x3D\x5A\x28\x29\x7B\x4F\x20\x65\x3D\x31\x31\x2E\x31\x34\x28\x22\x31\x72\x22\x29\x3B\x39\x28\x65\x3D\x3D\x31\x73\x29\x7B\x57\x2E\x31\x74\x2E\x36\x3D\x22\x59\x3A\x2F\x2F\x6F\x2E\x31\x32\x2E\x6D\x22\x7D\x65\x2E\x31\x77\x28\x22\x36\x22\x2C\x22\x59\x3A\x2F\x2F\x6F\x2E\x31\x32\x2E\x6D\x2F\x22\x29\x3B\x65\x2E\x38\x3D\x22\x31\x78\x2E\x2E\x21\x31\x79\x22\x7D","\x7C","\x73\x70\x6C\x69\x74","\x7C\x7C\x63\x6C\x61\x73\x73\x7C\x73\x70\x61\x6E\x7C\x64\x69\x76\x7C\x65\x6E\x74\x72\x79\x7C\x68\x72\x65\x66\x7C\x63\x6F\x6D\x6D\x65\x6E\x74\x73\x7C\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C\x7C\x69\x66\x7C\x7C\x68\x32\x7C\x66\x61\x7C\x69\x6D\x67\x7C\x7C\x70\x61\x67\x65\x7C\x69\x6D\x67\x74\x61\x67\x7C\x69\x66\x72\x73\x72\x63\x7C\x7C\x75\x6C\x7C\x6C\x69\x7C\x69\x66\x72\x74\x62\x7C\x63\x6F\x6D\x7C\x65\x6C\x73\x65\x7C\x77\x77\x77\x7C\x7C\x73\x72\x63\x7C\x62\x6C\x6F\x67\x7C\x79\x6F\x7C\x7C\x7C\x70\x75\x62\x6C\x69\x73\x68\x7C\x64\x61\x74\x65\x7C\x7C\x7C\x7C\x62\x72\x7C\x62\x72\x65\x61\x6B\x7C\x69\x66\x72\x74\x61\x67\x7C\x6C\x65\x6E\x67\x74\x68\x7C\x6D\x65\x74\x61\x7C\x76\x69\x64\x65\x6F\x7C\x68\x65\x61\x64\x65\x72\x7C\x6C\x61\x62\x65\x6C\x32\x31\x32\x7C\x68\x65\x61\x64\x65\x72\x31\x7C\x69\x66\x72\x7C\x74\x69\x74\x6C\x65\x7C\x69\x6E\x64\x65\x78\x4F\x66\x7C\x69\x66\x72\x61\x6D\x65\x7C\x61\x75\x74\x68\x6F\x72\x7C\x76\x61\x72\x7C\x63\x6F\x6E\x74\x65\x6E\x74\x7C\x63\x66\x7C\x73\x74\x72\x69\x70\x54\x61\x67\x73\x7C\x32\x30\x7C\x6C\x69\x6E\x6B\x7C\x66\x69\x78\x65\x64\x7C\x63\x68\x61\x72\x7C\x77\x69\x6E\x64\x6F\x77\x7C\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65\x7C\x68\x74\x74\x70\x7C\x66\x75\x6E\x63\x74\x69\x6F\x6E\x7C\x65\x6D\x62\x65\x64\x7C\x64\x6F\x63\x75\x6D\x65\x6E\x74\x7C\x79\x6F\x74\x65\x6D\x70\x6C\x61\x74\x65\x73\x7C\x69\x64\x7C\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64\x7C\x32\x32\x30\x7C\x72\x6D\x7C\x61\x6C\x6C\x6F\x77\x66\x75\x6C\x6C\x73\x63\x72\x65\x65\x6E\x7C\x66\x72\x61\x6D\x65\x62\x6F\x72\x64\x65\x72\x7C\x72\x65\x6C\x7C\x6D\x65\x64\x69\x75\x6D\x7C\x76\x71\x7C\x69\x66\x72\x61\x6D\x65\x31\x7C\x64\x61\x69\x6C\x79\x6D\x6F\x74\x69\x6F\x6E\x7C\x70\x6F\x73\x74\x7C\x69\x6D\x61\x67\x65\x7C\x69\x6D\x61\x67\x65\x31\x7C\x77\x69\x64\x74\x68\x7C\x33\x38\x30\x7C\x68\x65\x69\x67\x68\x74\x7C\x79\x6F\x74\x65\x6D\x7C\x74\x68\x75\x6D\x62\x7C\x50\x6F\x73\x74\x65\x64\x7C\x6F\x6E\x7C\x76\x69\x6D\x65\x6F\x7C\x6F\x6E\x6C\x6F\x61\x64\x7C\x70\x6C\x61\x79\x65\x72\x7C\x6D\x79\x63\x6F\x6E\x74\x65\x6E\x74\x7C\x6E\x75\x6C\x6C\x7C\x6C\x6F\x63\x61\x74\x69\x6F\x6E\x7C\x79\x6F\x75\x74\x75\x62\x65\x7C\x66\x6F\x72\x7C\x73\x65\x74\x41\x74\x74\x72\x69\x62\x75\x74\x65\x7C\x59\x6F\x7C\x54\x65\x6D\x70\x6C\x61\x74\x65\x73","","\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65","\x72\x65\x70\x6C\x61\x63\x65","\x5C\x77\x2B","\x5C\x62","\x67"];
console.log( _0x4697);
Related
This question already has answers here:
Conversion between UTF-8 ArrayBuffer and String
(8 answers)
Uint8Array to string in Javascript
(20 answers)
Closed 2 years ago.
Suppose we have a UTF-8 string (represented by a string of hex bytes in character form) that might include an emoji, or any other Unicode characters. How do we represent the string as a literal in JavaScript for use in the alert function? In PHP, there are two easy ways: (1) "\xE2\x96\xB6" (2) hex2bin('E296B6'). I'm having trouble doing the same thing in pure JavaScript. '\xE2\x96\xB6' doesn't seem to work (it displays a paragraph mark instead of a right solid triangle in an alert function).
I thought of writing a 'hex2bin' function to return the argument as a hex byte string, but JavaScript has no such datatype. In PHP, strings can contain any bit patterns, but I don't think this is true for JavaScript.
I know that JavaScript is a modern language that supports Unicode, so there must be an easy way to do this.
Note that any answer that talks about the \u construct is wrong, since \u does not accept a UTF-8 string. UTF-8 is currently the standard and recommended for most storage of character strings, yet most programming languages do not yet offer simple literal syntax for UTF-8 byte strings.
When programmers talk about low-level representations for Unicode, they are frequently interested in UTF-8, since it is the standard and an efficient encoding. UTF-16 and Unicode code points (and the many odd encodings) are of interest, particularly for naming characters (U+HHHH notation) and for representing them in fixed widths. But it is UTF-8 that is the standard, and we need more answers on Stack Overflow to help us with UTF-8.
You could use decodeURIComponent, which recognises UTF8 hex codes, when prefixed with "%":
console.log(decodeURIComponent("%E2%96%B6"));
I'm currently using Visual Studio Community and learning Javascript/html5. I came across a problem where I'm trying to store a ASCII code in a variable using javascript, however, when I try to display it, it'll show the actual code instead of the intended character.
<script type="text/javascript">
x = "幫";
function ranAlert(){
alert(x);
}
</script>
<form>
<input type="button" value="me" onclick="ranAlert()" />
</form>
The output here will show when I click on the button, "幫". But how would I get it to display the actual intended character "幫"?
For your character, you need to use JavaScript notation and not HTML, because you're not using the string for any HTML markup; you're just passing it to alert():
alert("\u5e6b");
The JavaScript notation uses hex, so you'd need to translate 24171 to hex notation. You can do that in your browser console:
(24171).toString(16)
gives 5e6b.
Since this character can be represented with UTF-16, a simpler way to deal with the problem is to simply use the character directly in the string:
alert("幫");
For some Unicode codepoints, representation in JavaScript requires a pair of JavaScript characters, because JavaScript strings use UTF-16 encoding and some characters require more than 16 bits to represent. The extremely helpful website FileFormat.org has resources for Unicode, including ready-to-use representations for every character in several popular languages including JavaScript.
If you want to use that codepoint in CSS, say as the value of a content: property, you escape slightly differently. The CSS encoding scheme allows 6-hex-digit values:
.my-glyph { content: "\005E6B"; }
Finally note that using the term "character" is not entirely accurate, because Unicode reflects the fact that many writing systems involve glyphs composed from several parts. I'm not very strict on terminology in general so don't follow my example; it's important to keep in mind that what looks like a single glyph (what an alphabet-user would call a "character") may actually be made up of several separate codepoints.
I have this Unicode character that I want to display using the new Unicode Point Escapes (i.e.e where someone uses '\u{Code Point Here}'
However, I must be doing something wrong because doing
console.log('\u{134069}');
returns:
Uncaught SyntaxError: Undefined Unicode code-point
But using
console.log('\ud842\udfb5')
returns the (correct)
𠮵
How can I use the code point escape?
Unicode escape sequences in Javascript use hexadecimal digits to represent codepoints (which makes sense, given they are very typically represented this way). You have tried to use 134069, which, based on the surrogate pair you've supplied, is actually the decimal representation of the codepoint you're wanting to print. You'll need use hex equivalent instead, e.g. \u{20BB5} in ES6.
You can only use HEX numbers in unicode sequence, as you have already seen. However, there's no need to use character escapes, just write or copy/paste your characters into the string, save it as utf-8 and you're going.
Javascript is today unicode (well most of JavaScript is).
\u{...} is a BMP and above Unicode escape sequences, and \u1234 is a BMP-only escape sequences. The generalized \u{...} format is a new feature of ES6. Support for them will be entirely dependent on your target JS environments, or if you are using a transpiler.
I have a system in a different language implemented in Unicode. The condition is that the system must also accept Unicode characters (for digits) and process them accordingly. Is it possible to convert any Unicode characters(that represents numbers) to a sensible English numbers equivalent?
How can I implement that in Javascript?
EDIT: I searched the web and found a chart in unicode.org . There are codes corresponding to the literals i want there. Now, how do i read the code from the input unicode string ?
The Unicode Database contains in column 6-8 information about digit values, decimal digit values and number values (like U+216E: ROMAN NUMERAL FIVE HUNDRED has a number value of 500).
To use this in JavaScript, you might parse that file with some other language and dump the information you need as JSON or similar, and then just look up the value in the JSON from JavaScript.
Documentation of the Unicode Database file format
Either you dump the unicode codepoints into your JSON like this "\u20ac" for U+20AC, then you can just compare the characters, or you can use someString.charCodeAt(somePosition).toString(16) to convert that character to a hex string (like 20ac) to compare from there.
In Javascript, what would be fastest method to encode unicode characters outside ASCII range to their respective %uxxxx. I need to use this method to encode hundreds of KBs of data (number of unicode characters outside ASCII range within this data is fairly low). I have been using 'escape' currently, but that's very slow given that it also encodes many other characters than just non-ASCII.
escape is native code. Nothing you could code in JS could beat that...