0

It would be nice if I could search for the Unicode escape sequence of a particular character using the browser JavaScript console or via a bookmarklet. Is there any way to easily do this?

3

1 Answer 1

0

Here is a function which can be run from the console or saved as a bookmarklet to generate a Unicode lookup table:

function Unicode()
  {
  var i = 0, unicode = {}, zero_padding = "0000", max = 9999;
  //Loop through code points
  while (i < max) {
    //Convert decimal to hex value, find the character, then pad zeroes to the codepoint
    unicode[String.fromCharCode(parseInt(i, 16))] = ("u" + zero_padding + i).substr(-4);
    i = i + 1;
    }

  //Replace this function with the resulting lookup table
  Unicode = unicode;
  }

//Usage
Unicode();
Unicode["%"];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .