- What's the difference between encodeURIComponent and encodeURI?
- encodeURIComponent escapes every reserved character (including / ? # & =), so use it for a single value like a search term or a query parameter. encodeURI keeps those characters, so use it to clean up a whole URL without breaking its structure.
- Should spaces be %20 or +?
- Both mean a space inside a query string. + comes from HTML form encoding (application/x-www-form-urlencoded) and is common in query strings; %20 works everywhere, including in paths. Turn on “+ for spaces” to match form-style URLs.
- Why do Thai URLs turn into long %E0%B8… strings?
- URLs can only carry ASCII, so each Thai character is turned into its 3 UTF-8 bytes, each written as %XX. Browsers show the readable Thai in the address bar, but the encoded form is what gets sent. Thai domain names use punycode (xn--…) instead.