升级 perl 模块 以及编码转换

本文介绍使用Perl进行不同字符集间的编码转换方法,包括从GBK到UTF-8、从UTF-8到GBK及从UTF-8到GB2312的具体实现。通过实际代码示例,展示了如何利用Perl内置模块Encode和URI::Escape进行字符串编码转换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

perl -MCPAN -e shell
install URI::Escape

 

编码转换

use Encode;
gbk转uft-8:
$line = encode("utf-8",decode("gbk",$line));

$line = encode_utf8(decode("gbk",$line));
utf-8转gbk:
$line = encode("gbk", decode("utf8", $line));
uft-8转gb2312:
$line = encode("gb2312", decode("utf8", $line));

 

#! /usr/bin/perl
use URI::Escape;
use Encode;
$encoded = "http:////db4.file.joy.cn//6ded5b63fbd8454cff52d11d7f83388b//vodflv//%e7%94%b5%e8%a7%86%e5%89%a7//100113-350k-%e8%a5%bf%e
6%b8%b8%e8%ae%b0//100113-350k-%e8%a5%bf%e6%b8%b8%e8%ae%b0-1.flv";
$decoded  = uri_unescape($encoded);
print "$decoded/n";
$decoded = encode("gb2312", decode("utf8", $decoded));
print "$decoded/n";

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值