Component or full URI — the distinction that breaks things
There are two encoding functions and picking the wrong one is the most common URL-encoding bug.
Component escapes the reserved characters &, =, ?, / and #. Use it for a single query value or path segment. If a search term contains an ampersand and you do not escape it, the URL splits into two parameters and the value is silently truncated.
Full URI leaves those characters alone, because in a whole URL they are doing their job as separators. Encoding a complete URL with the component function produces a string that is no longer a URL.
The plus-sign problem
In a query string, some parsers read + as a space — a legacy of HTML form encoding, which is subtly different from URL encoding. A literal plus sign in a value therefore has to be escaped as %2B, or it may arrive as a space. This catches people out most often with phone numbers in international format.
Fragments never reach the server
Everything after # is the fragment and is handled entirely by the browser — it is never sent in the HTTP request. If a value containing an unescaped # goes into a URL, everything after it silently disappears from the server's point of view.