Both percent-encoding and Base64 turn input into a restricted set of ASCII characters, both are reversible, and both are routinely described as "making a string safe". They are also answers to completely different questions, which is why choosing between them by feel produces data that survives the round trip in testing and falls apart in a log file three weeks later.
The distinction is one sentence long: percent-encoding protects characters that have syntactic meaning inside a URL, and Base64 re-encodes bytes that are not text at all. Get that backwards and nothing throws an exception β the value simply arrives different, or half of it arrives.
The rule, stated once
If what you have is text that must sit inside a URL component (a search term, a filename, a redirect target), percent-encode it for that component.
If what you have is bytes (an image, a hash, an encryption key, a protobuf), Base64 them β and then percent-encode the Base64 if it has to travel in a URL.
The second clause is the one peopleβ¦