Hi,
I am trying to convert a URL to its encoded equivalent. i.e. http://example.com/path with spaces/ to http://example.com/path%20with%20spaces/.
The problem I am facing is that rawurlencode or urlencode, encodes all the characters and does not show mercy upon the reserved characters such as '?', '#', '=' which makes the URL invalid after encoding. I understand that this behavior of these functions is expected considering the fact that they are to be used to encode data (such as query) that can be appended in an URL, but it isn't helping the current situation.
I thought of the following procedure to achieve the above: