ID:               23063
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mccarthy36 at earthlink dot net
 Status:           Wont fix
 Bug Type:         Feature/Change Request
 Operating System: All
 PHP Version:      4.3.1
 New Comment:

What's neither useful nor self-evident is what the value of encoding
alphanumerics and other non-special characters is.

You're absolutely right when you say that it's a simple matter to add
this function and that it won't break BC.  The reason this is marked
"Won't Fix", however, is because there are literally hundreds of such
functions which, while taken individually are trivial and harmless,
while taken together add up to a great deal of bloat.

Have you considered creating a PEAR class?  Possibly one which includes
other URL related functionality as well.  One of the reasons the PEAR
and PECL repositories were created (the chief reason in fact) was to
allow functions such as what you describe to be 'standard' without
adding to what is (let's be honest) an already overloaded scripting
engine.


Previous Comments:
------------------------------------------------------------------------

[2003-04-05 14:54:32] mccarthy36 at earthlink dot net

That's true.  You could also do the following and dispense with the
built in functions entirely, but it's not very convenient (and perhaps
less efficient?).

preg_replace( array( '/[^\w. -]/e', '/ /' ), array( "sprintf( '%%%02X',
ord( '\\0' ) ) ", '+' ), $foo_original );

preg_replace( '/[^\w.-]/e', "sprintf( '%%%02X', ord( '\\0' ) )",
$foo_original );

That's some pretty complicated code, that you have to go through the
hassle of carrying around with you everywhere you need it, to perform a
pretty simple action.  I don't understand why you just automatically
decided to condemn this to "Wont fix".  It seems like it would be
pretty simple to implement, and the change I suggested wouldn't
interfere with anything.  The usefulness / necessity is self-evident
and demonstrated by the existence of the current built in functions.

------------------------------------------------------------------------

[2003-04-05 12:44:44] [EMAIL PROTECTED]

You can achieve the same results using preg_replace:

preg_replace('/./e',"sprintf('%%%02X',ord('\\0'))",$foo);

The resulting string can be parsed by any RFC compliant query string
decoder.

------------------------------------------------------------------------

[2003-04-05 11:29:14] mccarthy36 at earthlink dot net

I'd like to see an optional boolean second argument to urlencode() and
rawurlencode() to cause encoding of all characters in the argument
string, even alphanumerics.

Like this:
string urlencode ( string str [, bool encode_all])
string rawurlencode ( string str [, bool encode_all])

Naturally the optional argument would default to false to preserve the
current behavior.

Thanks

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=23063&edit=1

Reply via email to