Windows 7에서 Active Perl 5.14를 실행하고 있습니다. 변환 테이블을 읽어 들인 후 파일에서 작업하고 다른 패턴으로 바꾸는 프로그램을 작성하려고합니다. 패턴 - 위의 모든 것은 유니 코드 (UTF-8)로되어 있습니다.Perl + 유니 코드 : "Wide Strings"오류
wide character in print at (eval 155)E:/Active Perl/lib/Perl5DB.pl:640]line 2, <CONVTABLE> line 1, etc...
은 왜이다 :
#!/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";
my $sta= open (CONVTABLE, "<:encoding(utf8)", 'E:\My Documents\Perl\Conversion table.txt');
binmode STDOUT, ':utf8'; # output should be in UTF-8
# Load conversion hash
while (<CONVTABLE>) {
chomp;
print "$_\n"; # etc ...
# etc ...
그것은이 시점에서, 그것이라고 밝혀 다음은 프로그램의 시작인가? 유니 코드 문자열을 올바르게 처리하고, 디코딩하고, UTF-8로 인코딩하는 데 필요한 모든 처방을 구현했다고 생각합니다. 어떻게 고칠 수 있습니까?
TIA
헬렌
코드는 문제가 없습니다. 디버거 외부에서 실행하면 어떻게됩니까? – ikegami
그건 그렇고,'binmode STDOUT, ': utf8';'는'open qw <: std : utf8>;에 의해 수행되는 것과 동일하게 중복됩니다. – ikegami
그건 그렇고,'use feature qw; (코드에 아무런 영향을주지 않습니다)는'use 5.014; '에 의해 동일하게 중복되어 중복됩니다. –
ikegami