How can I safely encode special characters in the URL