Forums.ATC.no

Teknisk => Generelt teknisk => Emne startet av: ATC på 27. ſeptember 2008, 18:24 pm

Tittel: How to URL encode a string in Perl
Skrevet av: ATC27. ſeptember 2008, 18:24 pm
When passing "weird" characters in web forms, URLs etc. the HTTP standard requires them to be encoded as hex ASCII codes with leading % signs. Example:

"my fun stuff" = "my%20fun%20stuff"
Tittel: [Solved] How to URL encode a string in Perl
Skrevet av: ATC27. ſeptember 2008, 18:24 pm
Cast this regular expression on your string to encode it:

$string =~ s/([^A-Za-z0-9\.])/sprintf("%%%02X", ord($1))/seg;