Created
January 21, 2015 07:08
-
-
Save cakecatz/40eff0c4ab65ae479ae3 to your computer and use it in GitHub Desktop.
decodeUTF16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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