perl encode_utf8必须用在utf8环境
- [root@wx03 mojo]# cat test.pl
- use Mojolicious::Lite;
- use JSON qw/encode_json decode_json/;
- use Encode;
- no strict;
- use JSON;
- use Data::Dumper;
- # /foo?user=sri
- get '/admin/api/menu' => sub {
- my $c = shift;
- print "测试更健康\n";
- open (LOG1 ,"<",'/data01/applog_backup/zj-api01-catalina.out') or die $!;
- while (<LOG1>) {
- my $phone='18072722237';
- #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!
- if ( ($phone) and ($_ =~/$phone/) and ($_ =~/SMSUtils/) ){$str=$_;
- my $x='验证';
- print "\$x is $x\n";
- my $d=encode_utf8('验证');
- print "\$d is $d\n";
- print "1-------\$str is $str\n";
- next if ($str !~ /$d/);
- print "2--------\$str is $str\n";
- #push (@arr1 ,decode_utf8($str));
- push (@arr1 ,$str);
- }};
- close LOG1;
- $c->render(json => \@arr1 );
- };
- app->start;
- [root@wx03 mojo]# morbo test.pl
- Server available at http://127.0.0.1:3000
- Wide character in print at /root/mojo/test.pl line 10.
- 测试更健康
- Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 1.
- $x is 验证
- $d is 验证
- 1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为813231,本验证码30分钟内有效。 to phoneNo:18072722237 succeed!
- 2--------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为813231,本验证码30分钟内有效。 to phoneNo:18072722237 succeed!
- Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 3.
- $x is 验证
- $d is 验证
- 1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的813231,本30分钟内有效。 to phoneNo:18072722237 succeed!
- Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 4.
- $x is 验证
- $d is 验证
- 1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的813231,本30分钟内有效。 to phoneNo:18072722237 succeed!
- 此时$d和$x都正常显示
- [root@wx03 mojo]# cat c1.pl
- use Encode;
- my $x='验证';
- print "\$x is $x\n";
- my $d=encode_utf8('验证');
- print "\$d is $d\n";
- [root@wx03 mojo]# perl c1.pl
- $x is 验证
- $d is éªè¯
- 说明encode_utf8 必须用在utf8编码环境
perl encode_utf8必须用在utf8环境的更多相关文章
- encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.
use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' => 'Ken' , 'age' => 1 ...
- C、Shell、Perl基于Tomcat开发CGI程序环境配置
基于Tomcat7.0版本号配置CGI开发环境,步聚例如以下: 以我的Tomcat7安装文件夹为例:TOMCA_HOME = /Users/yangxin/Documents/devToos/java ...
- perl encode_utf8 和decode_utf8
encode_utf8 等于 $octets = encode_utf8($string); 这个字符串 在$string 在Perl的内部格式,返回结果是作为一个顺序的字节. 因为所有的可能的字符串 ...
- Eclipse 完全 设置UTF-8 环境
当开始一个新的Java项目时,最好将整个环境设置为UTF-8 一般通过如下几步来设置: 1: 设置工作空间的编码格式:Window -> Preferences -> General -& ...
- 理解perl的编码转换——utf8以及乱码
工作需要,闲暇之余,仔细研究了一下脚本乱码的问题 1. vim新建的文件 1)在linux命令行 vim命令建立的文件,如果内容中不出现中文,默认是ASCII.那么用notepad++打开的时候,就是 ...
- perl encode_json 会产生 UTF-8 (binary) string decode_json 需要一个 UTF-8 (binary) string
encode_json $json_text = encode_json $perl_scalar Converts the given Perl data structure to a UTF-8 ...
- perl use utf8
utf8 Perl编译 来启用/禁用 UTF-8(or UTF-EBCDIC) 在源代码里 简洁: use utf8; no utf8; # Convert the internal represen ...
- perl unload gbk oracle 数据库
perl unload gbk Oracle 数据库 use Encode; if ( $#ARGV < 0 ){ print "请输入一个文件\n"; exit(-1); ...
- 通过demo搞懂encode_utf8和decode_utf8
perl 编码问题: use utf8表示代码使用UTF-8写的 [root@wx03 0710]# cat a1.pl #use utf8; my $str='测试utf8字符集'; print $ ...
随机推荐
- IE读取并显示本地图像文件的方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- document.domain与js跨域的问题
以前如果要使iframe里面的脚本能访问parent的内容,但iframe和parent的二级域名相同,那一般都会在两者都写上document.domain="xxx.com" 以 ...
- float 保留两位小数
1.页面运算格式化数字 页面上有时候会用到数字的运算,运算过后会出现1.5999999999999这么长的数字,需要格式化数字,比如保留两位有效数字 首先导入这个标签 <%@ taglib ur ...
- MFC技术内幕系列之(四)---MFC消息映射与消息传递内幕
//////////////////////////////////////////////////////////////////////////////////// ...
- Tour(KM算法)
Tour Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submi ...
- 【MongoDB】windows平台搭建Mongo数据库复制集(相似集群)(一)
Replica Sets(复制集)是在mongodDB1.6版本号開始新增的功能.它能够实现故障自己主动切换和自己主动修复功能成员节点的功能,各个DB之间的数据全然一致,大大减少了单点故障的风险. ...
- C# 中根据datetime的值来计算属于本年的第几周,类似delphi中的weekoftheyear功能
/// <summary> /// 获得今天是今年的第几周 /// </summary> /// <param name="year">< ...
- NSnotificationCenter 正确使用姿势, removeObject 探索
最近在做平板的过程中,发现了一些很不规范的代码.偶然修复支付bug的时候,看到其他项目代码,使用通知的地方没有移除,我以为我这个模块的支付闪退是因为他通知没有移除的缘故.而在debug和看了具体的代码 ...
- ubuntu中在线升级python
sudo add-apt-repository ppa:fkrull/deadsnakes-python2.7 sudo apt-get update sudo apt-get upgrade 笔记
- BZOJ 3282: Tree( LCT )
LCT.. -------------------------------------------------------------------------------- #include<c ...