To URL encode a string, replace unsafe characters with percent-codes (a space becomes %20); to decode, reverse it. Here is exactly which characters to encode.