[development] URL encoding

nitin gupta nitingupta.iitg at gmail.com
Thu Mar 11 18:10:31 UTC 2010


@Earnie: I am not sure if this is affecting, but I will check it out.

I am using the following to solve the problem, any ideas to improve it in
terms of efficiency or otherwise are welcome:

function encodeurl($url) {
  $reserved = array(
    ":" => '!%3A!ui',
    "/" => '!%2F!ui',
    "?" => '!%3F!ui',
    "#" => '!%23!ui',
    "[" => '!%5B!ui',
    "]" => '!%5D!ui',
    "@" => '!%40!ui',
    "!" => '!%21!ui',
    "$" => '!%24!ui',
    "&" => '!%26!ui',
    "'" => '!%27!ui',
    "(" => '!%28!ui',
    ")" => '!%29!ui',
    "*" => '!%2A!ui',
    "+" => '!%2B!ui',
    "," => '!%2C!ui',
    ";" => '!%3B!ui',
    "=" => '!%3D!ui',
  );

  $url = rawurlencode(rawurldecode($url));
  $url = preg_replace(array_values($reserved), array_keys($reserved), $url);
  return $url;
}


--
Regards,
Nitin Kumar Gupta
http://publicmind.in/blog/


On Thu, Mar 11, 2010 at 10:01 PM, Earnie Boyd
<earnie at users.sourceforge.net>wrote:

> nitin gupta wrote:
>
>>  I am currently just testing with spaces. Its strange that the above
>>  wasn't converted to:
>>
>>  http://test.com/test%20dfsdaf%20dsfsadf
>>
>>
>>  on my machine. I am using D6.15 with PHP 5.3.
>>
>>
> Are you aware of http://drupal.org/node/360605 ?
>
>
> --
> Earnie
> -- http://www.give-me-an-offer.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100311/1f544874/attachment.html 


More information about the development mailing list