cakecatz
1/21/2015 - 7:08 AM

decodeUTF16

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;
};