检测URL参数中的错误字符

I've been getting logs in my error log, which I've tracked down to be a problem with bad characters being send as URL parameters. My problem is that i don't know how to detect those in my code to be able to return a proper error message.

This is the parameter that is making a mess:

%E2%80%A2%C2%B0$%CallmeG.G%25$%C2%B0%E2%80%A2&name%5B35%5D

After urldecoding, this will be:

•°$�llmeG.G%$°•

I can see that something goes wrong here with the "�". Which is the only character messing up my code. However I am not sure how to detect this or help the problem.

If you

urldecode('%Ca');

the output is

You need to remove (or escape) the '%' preceding 'Ca'.