perl中两个urldecode和urlencode的方法

2006-08-02

urlencode / urldecode in Perl

If you are looking for PHP’s urlencode/urldecode equivalent in Perl, you won’t find any. But here’s what you can do:

Encode:

$str =~ s/([^A-Za-z0-9])/sprintf(“%%%02X”, ord($1))/seg;

Decode:

$str =~ s/%([A-Fa-f0-9]{2})/pack(‘C’, hex($1))/seg;

分类:技术 | 标签: |

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注