Skip to content

Instantly share code, notes, and snippets.

@remy
Created April 22, 2010 11:26
Show Gist options
  • Save remy/375100 to your computer and use it in GitHub Desktop.
Save remy/375100 to your computer and use it in GitHub Desktop.
challenge: unicode to unicode
/**
* == Can it be done? ==
*
* I want to get from keyIdentifier to actual character, eg from U+0023
* to \u0023 - which if dropped in a string is the # character:
* http://jsconsole.com/?%22\u0023%22
*
* The problem is the starting point, and I know I can do it using an
* eval, but eval is evil, right? So how can I do it?
*
* Can you solve this?
* - @rem
*/
var code = "U+0023";
// evil - but works :-(
eval('"' + code.replace(/^U\+/, '\\u') + '"')
// http://jsconsole.com/?eval('%22'%20+%20%22U+0023%22.replace(/^U\+/,%20'\\u')%20+%20'%22')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment