csthflk has asked for the wisdom of the Perl Monks concerning the following question:
When I run the program on Windows, the outputted file consists of correct Unicode characters. When I run the same program on Linux or MacOS, the file consists of gobbledy-gook. Whether I run on Windows, Mac, or Linux, the debug statements show the same exact sorts of results (as if it is doing the right thing):print OUT chr(charnames::vianame("$symbolName"));
use charnames ":full"; binmode(STDOUT, ":utf8"); %mapUnicode = (); open(MAP, "map2.txt") or die "!"; while(<MAP>) { next if (/^#/); next if ($_ !~ /[A-Z]/); chomp; if (length $_ > 0) { my @mapInfo = split / ### /; $mapUnicode{"$mapInfo[0]"} = $mapInfo[2]; } } close(MAP); open IN, "greekwords1.txt" or die "!"; open OUT, ">:utf8", "greekwords2.txt"; $buffer = ""; while(<IN>) { chomp; my $word = $_; print "\nWord is $word\n"; while($word =~ m/(.)/g) { my $newPart = $1; my $prospectiveUnit = "$buffer$newPart"; if (exists $mapUnicode{$prospectiveUnit}) { $buffer = $prospectiveUnit; } else { my $symbolName = $mapUnicode{$buffer}; print "Writing $buffer as $symbolName\n"; print OUT chr(charnames::vianame("$symbolName")); $buffer = "$newPart"; } } my $symbolName = $mapUnicode{$buffer}; print "Writing $buffer as $symbolName\n"; print OUT chr(charnames::vianame("$symbolName")); $buffer = ""; print OUT "\n"; } close IN; close OUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unicode issues on Unix only
by kcott (Archbishop) on Nov 07, 2013 at 09:17 UTC | |
by csthflk (Novice) on Nov 07, 2013 at 19:00 UTC | |
|
Re: unicode issues on Unix only
by graff (Chancellor) on Nov 07, 2013 at 03:19 UTC | |
by Anonymous Monk on Nov 07, 2013 at 18:58 UTC | |
|
Re: unicode issues on Unix only
by daxim (Curate) on Nov 06, 2013 at 17:55 UTC | |
by csthflk (Novice) on Nov 06, 2013 at 18:37 UTC | |
by Anonymous Monk on Nov 06, 2013 at 20:50 UTC | |
by csthflk (Novice) on Nov 06, 2013 at 21:47 UTC |