在Perl中解码UTF-8 URL [英] Decode UTF-8 URL in Perl
本文介绍了在Perl中解码UTF-8 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑:
use URI::Escape;
print uri_unescape("%C3%B3");
输出:ó
对此进行解码 http://meyerweb.com/eric/tools/dencoder/
输出:ó
这是预期的值。
什么是Perl我应该使用库来获取正确的输出吗?
What Perl library should I use to get the correct output?
推荐答案
如果您知道字节序列为 UTF-8 ,然后使用 Encode :: decode
:
If you know that the byte sequence is UTF-8, then use Encode::decode
:
use Encode;
use URI::Escape;
my $in = "%C3%B3";
my $text = Encode::decode('utf8', uri_unescape($in));
print length($text); # Should print 1
这篇关于在Perl中解码UTF-8 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文