Flex- handle error thrown by decodeURIComponent component for some utf-8 encoded strings

357 views Asked by At

How to I handle the erros thrown by the decodeURIComponent. By handling I mean that when the decodeURIComponent throws some error I want that the characters which caused the issue to be stripped out or replaced by some default charcters.

In my case i have an encoded string which contains the 'emojis' url encoded like this '%20%f0%9f%98%8f'. So when i try to decode it using decodericomponent it creates an error may be beacuse doesn't support unicoded character.

One way i thought of handling this is If the decodeuricomponent throws an error then create a custom function that would first replace all emojis utf-8 represtations (http://apps.timwhitlock.info/emoji/tables/unicode) with some default characters and then deocde it.

Say for eg: replace occurence of '%F0%9F%98%8A' with ':)' and so on.

But what if there are still some cases left out. Then it would again throw an error.

Can anybody help out.

Thanks in advance.

0

There are 0 answers