Skip to content

Instantly share code, notes, and snippets.

@leodutra
Last active December 15, 2015 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leodutra/5196223 to your computer and use it in GitHub Desktop.
Save leodutra/5196223 to your computer and use it in GitHub Desktop.
Converts Array, String or Number to Unicode String
function toUnicode(val/* :Array|Number|String */) {
var res = '';
var type = $.type(val);
var i;
switch(type) {
case 'array':
val = s.join('');
case 'string':
case 'number':
i = (val + '').length;
res = Array(i);
while (i--) res[i] = '\\u' + ('000' + val.charCodeAt(i).toString(16)).substr(-4);
res = res.join('');
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment