Encode strings into a URL-safe format (percent-encoding) or decode URL-encoded strings back into standard text.
URL encoding, also known as percent-encoding, is a process used to convert characters into a format that can be safely transmitted over the internet via Uniform Resource Locators (URLs). URLs can only contain a limited set of characters (alphanumeric characters and a few special symbols like -, _, ., ~).
Any other characters, such as spaces, punctuation, or non-ASCII characters, must be encoded. This involves replacing the unsafe character with a '%' symbol followed by the two-digit hexadecimal representation of the character's ASCII or UTF-8 value.
Encoding converts unsafe characters in your text into the %HH format. For example, a space character becomes %20, an exclamation mark becomes %21, and the character 'é' might become %C3%A9 (using UTF-8). This ensures that the data remains intact and correctly interpreted when included in a URL query string or path.
Decoding reverses the process, converting the %HH sequences back into their original characters. This allows applications or servers receiving the URL to correctly interpret the intended data, such as search terms, parameters, or file paths.