Perl 中文件句柄的 UTF-8 编码
我将 UTF-8 编码应用于 STDIN 和 STDOUT。但是,如何确保将 UTF-8 编码应用于传递给下面代码的文件(如果在命令行上传递文本文件,<> 将从文件而不是 STDIN 中读取)线尽可能。
use open qw(:std :utf8)
while (<>) {
print;
}
I'm applying UTF-8 encoding to STDIN and STDOUT. However how do I make sure that I apply UTF-8 encoding to the file that I pass to my code below (<> will read from a file instead of STDIN if a text file is passed on the command line) in as few lines as possible.
use open qw(:std :utf8)
while (<>) {
print;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据
open
pragma 的文档,您已经获得了所需的行为:perlop 文档告诉我们
while (<>) { ... }
相当于According to the
open
pragma's documentation, you've already got the behavior you want:The perlop documentation tells us that
while (<>) { ... }
is equivalent to