$str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
Now, the reverse, decode a string from a url. Equivalent of urldecode in PHP.
$str =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
2807 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
$str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
$str =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;
You need to create an account or log in to post comments to this site.