0

There are multiple classes and functions in different Programming Languages for encoding and decoding strings to be URL friendly. For example

in java

URLEncoder.encode(String, String)

in PHP

urlencode ( string $str )

And ...

My question is, If I UrlEncode a String in java, can I expect the other different UrlDecoders in other Languages decode to the same original sting?

I'm creating a Service that needs to encode some Base64 value in query string and I have no idea who are serving to. Please consider the only option I have here seems to be the query string. I can't use xml or json or HTTP headers Since I need this to be in a url to be redirected. I looked around and there were some questions exactly like this but non of them had a proper answer. I appreciate so much for any acknowledge or any solutions.

EDIT:

For example in PHP Manual there is this description:

Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type. This differs from the ยป RFC 3986 encoding (see rawurlencode()) in that for historical reasons, spaces are encoded as plus (+) signs.

That sounds it does not follow the RFC

madz
  • 1,803
  • 18
  • 45

1 Answers1

0

It sounds url encoders can use various algorithms in different Programming Languages.

But one should look for the encoding schema for every function. For example one of them could be

application/x-www-form-urlencoded

looking into JAVA Url Encoder:

Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.

Also looking into PHP's

that is the same way as in application/x-www-form-urlencoded media type

So if you are looking for a Cross Platform Url Encoding you should tell your users what is the format of your encoder. This way, they can found the appropriate Decoder or otherwise they can implement their own.
After some investigation, sounds application/x-www-form-urlencoded is the most popular among others.

madz
  • 1,803
  • 18
  • 45