perl use utf8
utf8 Perl编译 来启用/禁用 UTF-8(or UTF-EBCDIC) 在源代码里 简洁: use utf8;
no utf8; # Convert the internal representation of a Perl scalar to/from UTF-8. $num_octets = utf8::upgrade($string);
$success = utf8::downgrade($string[, $fail_ok]); # Change each character of a Perl scalar to/from a series of
# characters that represent the UTF-8 bytes of each original character. utf8::encode($string); # "\x{100}" becomes "\xc4\x80"
utf8::decode($string); # "\xc4\x80" becomes "\x{100}" # Convert a code point from the platform native character set to
# Unicode, and vice-versa.
$unicode = utf8::native_to_unicode(ord('A')); # returns 65 on both
# ASCII and EBCDIC
# platforms
$native = utf8::unicode_to_native(65); # returns 65 on ASCII
# platforms; 193 on
# EBCDIC $flag = utf8::is_utf8($string); # since Perl 5.8.1
$flag = utf8::valid($string) 描述: 使用utf8 编译告诉perl解析器 允许UTF-8在程序文本在当前的词法范围。 no utf8 编译告诉Perl 切回到对待文本作为literal 字节在当前的词法范围。 (在EBCDIC 平台,技术是允许UTF-EBCDIC, 不是UTF-8. 但是这个区别是学术的,因此在这个文件术语UTF-8是用于两者) 不要使用这个编译除了告诉Perl你的脚本是用UTF-8写的。 下面的描述是直接使用没有use utf8: 因为它不可能可靠的告诉UTF-8 从本地的8位编码, 你需要一个字节顺序标记在你的源代码的开始,或者use utf8,来指导perl 当UTF-8 变为标准的源代码格式,这个指令会有效的 变成一个 no-op 也可以查询-C切换的影响和它的cousin, PERL_UNICODE 环境变量 启动utf8程序有下面的影响: 在源文本中的字节不是以 ASCII character set 会被对待一个 literal UTF-8 sequence的一部分。 这包括很多的literals 比如标识符名称,字符串常量,和恒定的正则表达式模式。 注意如果你有non-ASCII, non-UTF-8 字节在你的脚本 use utf8会不高兴。因为你需要有这样的字节在use utf8, 你可以禁用这个程序直到最后的块(或者文件,如果在顶层) 通过使用no utf8 有用的函数; 下面的函数是定义在e utf8:: package,你不需要say use utf8 来使用那些 实际上 你不应该say 除非你真的需要UTF-8源代码
perl use utf8的更多相关文章
- perl unload utf-8 oracle 数据库
perl unload utf-8 Oracle [oracle@oadb sbin]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Produc ...
- perl unload utf-8 oracle Wide character in print at unload_oracle.pl line 105.
#!/usr/bin/perl use DBI; use Encode; my $dbName = 'oadb'; my $dbUser = 'vxspace'; my $dbUserPass = ' ...
- perl unicode utf-8 \x转换
[root@dr-mysql01 ~]# cat x5.pl use Encode; use JSON; use URI::Escape; use LWP::Simple; my $host = &q ...
- perl oracle utf-8 结果匹配中文字符
[oracle@oadb sbin]$ cat s1.pl #!/usr/bin/perl use DBI; use Encode; use HTTP::Date qw(time2iso str2ti ...
- Perl中文/unicode/utf8/GB2312之间的转换
参考:http://daimajishu.iteye.com/blog/959239不过具测试,也有错误:原文如下: # author: jiangyujieuse utf8; ##在最后一个例子, ...
- perl 学习笔记
一:基础 1:安装perl centos: yum -y install perl 官网:https://www.perl.org/ 升级到5.22:先下载,执行./i ...
- 【转】Perl Unicode全攻略
Perl Unicode全攻略 耐心看完本文,相信你今后在unicode处理上不会再有什么问题. 本文内容适用于perl 5.8及其以上版本. perl internal form 在Perl看来, ...
- Perl Unicode全攻略
Perl Unicode全攻略 耐心看完本文,相信你今后在unicode处理上不会再有什么问题. 本文内容适用于perl 5.8及其以上版本. perl internal form 在Perl看来, ...
- perl字符集处理
本文内容适用于perl 5.8及其以上版本. perl internal form 在 Perl看来, 字符串只有两种形式. 一种是octets, 即8位序列, 也就是我们通常说的字节数组. 另一种u ...
随机推荐
- Android EditText 无法换行
问题 关于控制是否换行的属性android:singleLine 当值为true的时候,只能一行,不换行 当值为false的时候,可以换行 但是现在遇到一个问题: <EditText andro ...
- Android 的平台碎片化问题
Android 的平台碎片化问题 看到篇不错的文章,转载过来. -------------------------------------- 与iOS开发相比,Android开发平添了不小的工作量,因 ...
- 将 Java Spring Framework 应用程序迁移到 Windows Azure
我们刚刚发布了一个新教程和示例代码,以阐述如何在Windows Azure中使用 Java 相关技术.在该指南中,我们提供了分步教程,说明如何将 Java Spring Framework 应用程序( ...
- 在MDK中怎样生成*.bin格式的文件?
在Realview MDK的集成开发环境中.默认情况下能够生成*.axf格式的调试文件和*.hex格式的可运行文件. 尽管这两个格式的文件很有利于ULINK2仿真器的下载和调试,可是ADS的用户更习惯 ...
- 误mlogc.c:32:23: error: curl/curl.h: No such file or directory
出现以下错误: mlogc.c:32:23: error: curl/curl.h: No such file or directory mlogc.c:1091: error: expected ' ...
- 一个IP每天只弹一次广告窗口
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- 【转】理解RESTful架构
[转]理解RESTful架构 越来越多的人开始意识到,网站即软件,而且是一种新型的软件. 这种"互联网软件"采用客户端/服务器模式,建立在分布式体系上,通过互联网通信,具有高延时( ...
- CentOS安装rar及用法
1.下载安装rar wget http://www.rarsoft.com/rar/rarlinux-x64-5.4.b3.tar.gztar -zxvf rarlinux-x64-.tar.gz - ...
- PHP MYSQL数据字典
<?php /** * 生成mysql数据字典 */ header ( "Content-type: text/html; charset=utf-8" ); // 配置数据 ...
- CodeForces 276D – Little Girl and Maximum XOR 贪心
整整10个月后第二次搞这个问题才搞懂........第一次还是太随意了. 解题思路: 经过打表可得规律答案要么是0 要么是2的N次 - 1 要得到最大的XOR值,其值一定是2的N次 - 1 即在 l ...