Skip to content

Instantly share code, notes, and snippets.

@cakecatz
Created January 21, 2015 07:08
Show Gist options
  • Select an option

  • Save cakecatz/40eff0c4ab65ae479ae3 to your computer and use it in GitHub Desktop.

Select an option

Save cakecatz/40eff0c4ab65ae479ae3 to your computer and use it in GitHub Desktop.
decodeUTF16
var decodeUTF16 = function(text) {
var decoded_str = '';
var arr = text.split(';');
for (var i=0;i<arr.length;i++) {
if (arr[i].search('&#x') !== 0) {
var raw_char = arr[i].replace(/&#([a-zA-Z0-9]+)/gm,'');
decoded_str += raw_char;
arr[i] = arr[i].replace(raw_char, '');
}
var c = arr[i].replace(/&#([a-zA-Z0-9]+)/gm,'0$1');
decoded_str += String.fromCharCode( parseInt( c ));
}
return decoded_str;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment