Peter wrote:
Hi all,

there seems to be a slight difference between the function urlencode from php and the uri_escape in perl:

the encoded result of "test !"§$%&/()=" is different:
in php: test+%21%22%A7%24%25%26%2F%28%29%3D
in perl: test%20%21%22%3F%24%25%26%2F%28%29%3D

The difference is the space: in php it becomes a "+", in perl a "%20". Which one is (academic) correct and can perl be told to behave just as php does?

Thanks for any answer!
Peter


According to the RFC, the only escape codes defined are the hex ones, though "+" is a reserved character. The usage of + as an encoding for space is a not explicitly documented in any RFCs, but is in common use for representing a space *in the query component of URIs*. I'm not sure if web servers will handle it correctly in the path or filename component. Therefore, I'd say that uri_encode is correct.


I don't believe there's a way to get the uri_encode function to do that for you, but you can translate before or substitute after if you really need them to match.

--
Matt Howard <[EMAIL PROTECTED]>


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to