Hi,<br><br>I am not creating the URL, but I parse the URL from XML content and I want to urlencode it. Also, I am looking to preserve all the reserved characters in the URL and not just &#39;?&#39; or &#39;&amp;&#39;.<br><br clear="all">

--<br>Regards,<br>Nitin Kumar Gupta<br><a href="http://publicmind.in/blog/">http://publicmind.in/blog/</a><br>
<br><br><div class="gmail_quote">On Thu, Mar 11, 2010 at 6:59 PM, Don <span dir="ltr">&lt;<a href="mailto:donald@fane.com">donald@fane.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




  

<div bgcolor="#ffffff" text="#000000">
If you use l() or url() the query section is passed separately, so the
&#39;?&#39; and &#39;&amp;&#39; are preserved. The query attributes are passed in an
array as name/value pairs. That&#39;s the real drupal way to make a link
also.<br><font color="#888888">
<br>
-Don-</font><div><div></div><div class="h5"><br>
<br>
On 3/11/2010 8:23 AM, nitin gupta wrote:
<blockquote type="cite">Hi,<br>
  <br>
I am trying to convert a URL to its encoded equivalent. i.e. <a href="http://example.com/path" target="_blank">http://example.com/path</a>
with spaces/ to <a href="http://example.com/path%20with%20spaces/" target="_blank">http://example.com/path%20with%20spaces/</a>.<br>
  <br>
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 &#39;?&#39;, &#39;#&#39;, &#39;=&#39; 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&#39;t helping the current
situation.<br>
  <br>
I thought of the following procedure to achieve the above:<br>
  <ol>
    <li>run rawurldecode on the input url, so that we do not
accidentally encode twice if whole or part of URL is already encoded.</li>
    <li>then run rawurlencode, and then preg replace these reserved
characters.</li>
  </ol>
Though it works, I am not sure if it is the correct way to handle this.
Any help through ideas or code will be highly appreciated as this will
be useful in <a href="http://drupal.org/project/feeds_imagegrabber" target="_blank">Feeds Image Grabber</a>
and <a href="http:///drupal.org/project/facebook_link" target="_blank">Facebook-style Links</a>
module.<br>
  <br>
Also, off the subject: shouldn&#39;t drupal_http_request() should take care
of such encoding?<br>
  <br>
  <br clear="all">
--<br>
Regards,<br>
Nitin Kumar Gupta<br>
  <a href="http://publicmind.in/blog/" target="_blank">http://publicmind.in/blog/</a><br>
</blockquote>
<br>
</div></div></div>

</blockquote></div><br>