• utf8字节


    <pre name="code" class="html">[root@wx03 0724]# perl a1.pl 
    112
    [root@wx03 0724]# perl a1.pl 
    dawe^H^H微信adda
    success
    [root@wx03 0724]# perl a1.pl 
    22微信3131 
    success
    [root@wx03 0724]# 
    
    [root@wx03 0724]# cat a1.pl 
    my $a=<STDIN>;
    my $b='微信';
    if ($a =~/$b/){print "success
    ";};
    
    
    
    [root@wx03 0724]# perl a1.pl 
    22微信3131
    [root@wx03 0724]# cat a1.pl 
    use Mojolicious::Lite;
    my $a=<STDIN>;
    my $b='微信';
    if ($a =~/$b/){print "success
    ";};
    
    此时匹配不上了:
    
    
    
    因为开启了utf8;
    
    [root@wx03 0724]# perl a1.pl 
    22微信3131
    success
    [root@wx03 0724]# cat a1.pl 
    use Mojolicious::Lite;
    use Encode;
    my $a=<STDIN>;
    my $b=encode_utf8('微信');
    if ($a =~/$b/){print "success
    ";};
    
    
    继续测试;
    [root@wx03 0724]# perl a1.pl 
    "my" variable $a masks earlier declaration in same scope at a1.pl line 4, <DATA> line 2125.
    23微信2231
    success
    
    [root@wx03 0724]# cat a1.pl 
    use Mojolicious::Lite;
    use Encode;
    my $a=<STDIN>;
    my $a=decode_utf8("$a");
    my $b='微信';
    if ($a =~/$b/){print "success
    ";};
    
    
    
    
    [root@wx03 0724]# perl a1.pl 
    "my" variable $a masks earlier declaration in same scope at a1.pl line 5, <DATA> line 2125.
    23微信2231
    $a is 23微信2231
    
    Wide character in print at a1.pl line 6, <STDIN> line 1.
    $a is 23微信2231
    
    success
    
    [root@wx03 0724]# cat a1.pl 
    use Mojolicious::Lite;
    use Encode;
    my $a=<STDIN>;
    print "$a is $a
    ";
    my $a=decode_utf8("$a");
    print "$a is $a
    ";
    my $b='微信';
    if ($a =~/$b/){print "success
    ";};
    
    
    
    /******************
    [root@wx03 0724]# perl a2.pl 
    23微信2231
    $b is 微信
    success
    
    [root@wx03 0724]# cat a2.pl 
    use Encode;
    use Mojolicious::Lite;
    my $a=<STDIN>;
    my $b=encode_utf8('微信');
    print "$b is $b
    ";
    if ($a =~/$b/){print "success
    ";};
    
    
    
    [root@wx03 0724]# perl a2.pl 
    23微信2231
    $b is 微信
    
    [root@wx03 0724]# cat a2.pl 
    use Encode;
    my $a=<STDIN>;
    my $b=encode_utf8('微信');
    print "$b is $b
    ";
    if ($a =~/$b/){print "success
    ";};
    [root@wx03 0724]# 
    


    
    
    
       
    
    
  • 相关阅读:
    苹果 macOS 安装 Source Code Pro
    C# 中代码执行 ping 操作
    WPF 中 Path 使用虚线
    查看 Java Web 开发环境软件是 32 位还是 64 位
    linux 磁盘io监控
    Linux下系统如何监控服务器硬件、操作系统、应用服务和业务
    ORA-00257: archiver error. Connect internal only, until freed 错误的处理方法
    完全卸载oracle11g步骤
    用JDBC连接SQL Server2017数据库
    oracle INS-13001 环境不满足最低要求
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199513.html
Copyright © 2020-2023  润新知