/ Published in: Perl
Expand |
Embed | Plain Text
#!/usr/bin/env perl use strict; use warnings; use CGI; use URI::Escape; my $q = new CGI; my $buf = $q->param('buf') || "This is an ampersand... &\n"; my $safe = uri_escape($buf); my $verysafe = uri_escape("foo", "\0-\377"); my $str = uri_unescape($safe); <html> <head> <title>URI Encoding</title> <script type="text/javascript"> function preencode() { var buf = document.getElementById('buf').value; document.getElementById('preencode').value = escape(buf); } </script> </head> <body> <form method="GET"> <input type="text" value="$buf" id="buf" name="buf" /> <input type="submit" /> </form> <div> <input type="text" value="" id="preencode" name="preencode" /> <button onclick="preencode()">Pre-encode</button> </div> <div> <h4>Safe</h4> <p>$safe</p> <h4>Very Safe</h4> <p>$verysafe</p> <h4>Str</h4> <p>$str</p> </div> </body> </html> ];
You need to login to post a comment.
