Skip to content

Instantly share code, notes, and snippets.

@leodutra
Last active December 15, 2015 03:39
Show Gist options
  • 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