我有一个宽字符文件(希伯来文本)在记事本中看起来很好(以"UTF-8编码"保存),在Notepad ++中读得很好,当我复制并粘贴到MS Word时它看起来也很好.但是当我打开一个"DOS框"(Windows控制台)并转到:"输入file.txt"时,它会打印出乱码.
是的,我在Windows控制台上完成了对Unicode的所有建议:我使用"cmd/u"打开控制台,我将字体更改为Lucida,然后输入:"chcp 65001".
运行Windows 7的PC和运行Windows XP SP3的另一台PC上的问题完全相同.
我在将Unicode字符串打印到Windows控制台*时遇到一个奇怪的问题.
考虑这个文字:
??? ???? ?????
Intermediary
??? ???? ?????
???, ??
Bye
Hello, world!
test
Run Code Online (Sandbox Code Playgroud)
假设它位于名为"file.txt"的文件中.
当我去*:"输入file.txt"时,它会打印出来.但是当它从Perl程序打印时,如下所示:
use strict;
use warnings;
use Encode;
use 5.014;
use utf8;
use autodie;
use warnings qw< FATAL utf8 >;
use open qw< :std :utf8 >;
use feature qw< unicode_strings >;
use warnings 'all';
binmode STDOUT, ':utf8'; # output should be in UTF-8
my $word;
my @array = ( '??? ???? ?????', 'Intermediary',
'??? ???? ?????', '???, ??', 'Bye','Hello, world!', 'test');
foreach $word(@array) {
say …
Run Code Online (Sandbox Code Playgroud) 我在Windows 7上运行Notepad ++ 5.8.5,编辑Perl程序.我想评论一段文本行(后来,或许,取消注释).
以下都不起作用:
CTRL+ K,CTRL+ Q,CTRL+ shift+ K,CTRL+ shift+ Q,
选择行块并转到菜单:edit-> Comment/Uncomment - > Block Comment
以上都没有任何影响.
该怎么办?
我正在开发一个处理外语数据的项目.我的Perl脚本运行正常.
然后我想使用Tie :: File,因为这是一个简洁的概念(并节省时间和编码).
看起来Tie:File在Unicode/UTF-8下失败了(除非我遗漏了什么).
这是一个描述问题的程序:(数据是英语,希腊语和希伯来语的混合):
use strict;
use warnings;
use 5.014;
use Win32::Console;
use autodie;
use warnings qw< FATAL utf8 >;
use Carp;
use Carp::Always;
use utf8;
use feature qw< unicode_strings>;
use charnames qw< :full>;
use Tie::File;
my ($i);
my ( $FileName);
my (@Tied);
binmode STDOUT, ':unix:utf8';
binmode STDERR, ':unix:utf8';
binmode $DB::OUT, ':unix:utf8' if $DB::OUT; # for the debugger
Win32::Console::OutputCP(65001); # Set the console code page to UTF8
$FileName = 'E:\\My Documents\\Technical\\Perl\\Eclipse workspace\\Work\\'.
'Tie File test res.txt';
tie @Tied, …
Run Code Online (Sandbox Code Playgroud) 我在Windows 7上运行Active Perl 5.14.我正在尝试编写一个程序,它将读入转换表,然后处理文件并用其他模式替换某些模式 - 以上所有Unicode(UTF-8) .这是该计划的开始:
#!/usr/local/bin/perl
# Load a conversion table from CONVTABLE to %ConvTable.
# Then find matches in a file and convert them.
use strict;
use warnings;
use Encode;
use 5.014;
use utf8;
use autodie;
use warnings qw< FATAL utf8 >;
use open qw< :std :utf8 >;
use charnames qw< :full >;
use feature qw< unicode_strings >;
my ($i,$j,$InputFile, $OutputFile,$word,$from,$to,$linetoprint);
my (@line, @lineout);
my %ConvTable; # Conversion hash
print 'Conversion table: opening file: E:\My Documents\Perl\Conversion table.txt'."\n"; …
Run Code Online (Sandbox Code Playgroud)