code: private String encodeIllegalCharacters(String relativeURI) {
          try {
              return new URI(null, null, relativeURI, null).toString();
          } catch (URISyntaxException e) {
              throw new LocationException(e);
          }
      }
docs: hand form-encodes all characters, even '/' which we do not want.