On 02 October 2003, Andy Eastham said:
> "Standard" one is java.net.URLEncoder.encode() and
> java.net.URLEncoder.decode()

No.  HTML quoting and URL encoding are quite different.

URLEncoder.encode() on my test string returns

  Jeb+said%2C+%22Hell+%26+damnation%21+Is+5+%3E+4%3F%22

(It would also be correct to replace every space with "%20".)

HTML quoting is for handling < > & and maybe " '.  Eg. Python's cgi.escape()
returns

  Jeb said, "Hell &amp; damnation! Is 5 &gt; 4?"

while Perl's CGI::escapeHTML() returns

  Jeb said, &quot;Hell &amp; damnation! Is 5 &gt; 4?&quot;

Hmmm, I see that Python's cgi.escape() has an optional arg to specify
quoting " characters.  Looks like Perl's CGI::escapeHTML() always quotes
quotes.  That's essential for cases like

  out.print("<input name=\"foo\" value=\"" + someUserSuppliedValue + "\"")

-- if someUserSuppliedValue has " characters in it, they must be quoted!

        Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to