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;
In reply to unicode issues on Unix only by csthflk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |