If a string contains character from interval U+D800..U+DFFF then encodeURIComponent() throws a malformed URI sequence error. I would like to eliminate those characters from a given string before passing it to encodeURIComponent(). How to do that?
Example: I have a textfile encoded in UTF-16BE which contains the following hexa chars:
D7FF D800 D801 ... DFFE DFFF E000
I'm searching for a function which returns this string from the string above:
D7FF E000
So only valid Unicode characters remain.