Snippet to encode string

Encode and string and remove invalid character from a URL
Remove encoding from url