7
$\begingroup$

URLEncode encodes spaces as plus symbols, but this isn't what we want:

The encoding used by default is based on a very early version of the general URI percent-encoding rules, with a number of modifications such as newline normalization and replacing spaces with "+" instead of "%20"

URLEncode["bad space"]
(*yields "bad+space", should be "bad%20space"*)

Is there any way to get the " "->"%20" behavior by default?

Related: https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20

$\endgroup$
1
  • 3
    $\begingroup$ Run Needs["GeneralUtilities`"]; PrintDefinitions[URLEncode] and you will see the definition. It's easy to copy that definition, change the " " -> "+" to " " -> "%20" and overwrite the default definition, if that's what you want. "should be" is a strong statement, considering that it appears to still be common to convert spaces into +. $\endgroup$
    – C. E.
    Commented Aug 10, 2016 at 22:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.