gpt4 book ai didi

perl - 在 Perl 中解码 UTF-8 URL

转载 作者:行者123 更新时间:2023-12-04 13:52:26 26 4
gpt4 key购买 nike

考虑:

use URI::Escape;
print uri_unescape("%C3%B3");

输出: ³

用这个解码 http://meyerweb.com/eric/tools/dencoder/

输出:ó

这是预期的。

我应该使用什么 Perl 库来获得正确的输出?

最佳答案

如果你知道字节序列是 UTF-8 ,然后使用 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 - 在 Perl 中解码 UTF-8 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13163937/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com