Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Which browser are you talking about? –  MoonSire Nov 12 '13 at 12:55
    
@MoonSire Any browser with a JavaScript command line: desktop, mobile, or game console –  Paul Sweatte Nov 12 '13 at 18:45
    
Ah ok, now I understand! –  MoonSire Nov 13 '13 at 4:17

1 Answer 1

up vote 0 down vote accepted

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["%"];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.