HelenCr has asked for the wisdom of the Perl Monks concerning the following question:
Hi wizards, I seek your wisdom.
I am running Active Perl 5.14 on Windows 7.
I am trying to write a program that will read-in a conversion table, then work on a file and replace certain patterns by other patterns - all of the above in Unicode (UTF-8). Here is the beginning of the program:
And how to fix it?
TIA
Helen
I am trying to write a program that will read-in a conversion table, then work on a file and replace certain patterns by other patterns - all of the above in Unicode (UTF-8). Here is the beginning of the program:
It turns out that at this point, it says:#!/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\Conversio +n table.txt'."\n"; my $sta= open (CONVTABLE, "<:encoding(utf8)", 'E:\My Documents\Perl\C +onversion table.txt'); binmode STDOUT, ':utf8'; # output should be in UTF-8 # Load conversion hash while (<CONVTABLE>) { chomp; print "$_\n"; # etc ... # etc ...
Why is that? I think I've gone through all the necessary prescriptions for correct handling of Unicode, decoding and encoding into UTF-8?wide character in print at (eval 155)E:/Active Perl/lib/Perl5DB.pl:640 +]line 2, <CONVTABLE> line 1, etc...
And how to fix it?
TIA
Helen
Note: I may cross-post on StackOverflow
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: print UTF-8 problem
by ikegami (Patriarch) on Feb 15, 2012 at 20:08 UTC | |
by HelenCr (Monk) on Feb 16, 2012 at 04:42 UTC | |
Re: print UTF-8 problem
by Anonymous Monk on Feb 15, 2012 at 19:25 UTC | |
by HelenCr (Monk) on Feb 15, 2012 at 19:55 UTC | |
by ikegami (Patriarch) on Feb 15, 2012 at 20:07 UTC | |
by HelenCr (Monk) on Feb 15, 2012 at 20:26 UTC | |
by ikegami (Patriarch) on Feb 15, 2012 at 20:30 UTC | |
| |
by ikegami (Patriarch) on Feb 15, 2012 at 20:33 UTC |
Back to
Seekers of Perl Wisdom