<pre name="code" class="html">[root@dr-mysql01 ~]# cat a1.pl
my $str="$ARGV[0]";
use Encode;
use Encode::CN;
use JSON;
use URI::Escape;
use LWP::Simple;
$str =~ s/\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print "$str";
[root@dr-mysql01 ~]# perl a1.pl "u767bu5f55u6210u529f"
Wide character in print at a1.pl line 8.
登录成功You have mail in /var/spool/mail/root
需要encode_utf8:
[root@dr-mysql01 ~]# cat a1.pl
my $str="$ARGV[0]";
use Encode;
use Encode::CN;
use JSON;
use URI::Escape;
use LWP::Simple;
$str =~ s/\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print encode_utf8($str);
[root@dr-mysql01 ~]# perl a1.pl "u6e29u91d1u6240"
温金所[root@dr-mysql01 ~]#
[root@dr-mysql01 ~]# cat hg.pl
use Encode;
use Encode::CN;
use JSON;
use URI::Escape;
use LWP::Simple;
open (LOG ,"<","hg.txt");
while (<LOG>){
$content=$_;
$content =~ s/\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print "$content";
http://download.baoxianziliao.com/tha/u4fdd/u9669/u516c/u53f8/u7231/u5fc3/u6fc0/u52b1/u4f1a/u7684/u529f/u80fd/u4e0e/u8fd0/u4f5c/u8981/u988623/u9875.ppt"
[root@dr-mysql01 ~]# cat a1.pl
my $str="gu4fddu9669u516cu53f8u7231u5fc3u6fc0u52b1u4f1au7684u529fu80fdu4e0eu8fd0u4f5cu8981u988623u9875.ppt";
use Encode;
use Encode::CN;
use JSON;
use URI::Escape;
use LWP::Simple;
$str =~ s/\u([0-9a-fA-F]{4})/pack("U",,hex($1))/eg;
print "$str";
[root@dr-mysql01 ~]# perl a1.pl
gu4fdd9669516c53f872315fc36fc052b14f1a7684529f80fd4e0e8fd04f5c89819886239875.ppt[root@dr-mysql01 ~]#