http://www.perlmonks.org?node_id=1015589

elef has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, this one is a bit unusual: my Tk app handles utf-8 strings entered into a Tk entry box fine, but when the same app is packaged into an exe with pp, some characters are corrupted. Specifically, ű becomes û and ő becomes õ (I hope these show up as intended here). They already show up incorrectly as you type them, and are printed to file incorrectly as well. This occurs both on Win7 and XP.
All other characters I tested are fine, including cyrillic and Arabic ones, but of course that's not entirely reassuring. How likely is it that other characters will also be corrupted? Is there any simple solution I could try? I can work around this with a simple s/û/ű/g but that's no help if many other unknown characters are also corrupted. Is this problem in Tk? pp? Windows?
Interestingly, the two problem characters work fine when pasted into the entry box instead of typing them in.
Here's a short script that exhibits the issue (I imagine you'll have to switch to the Hungarian keyboard layout if you want to test it, given that the problem doesn't occur if you use Ctrl-c Ctrl-v):
use strict; use warnings; use Tk; use utf8; my $mw = Tk::MainWindow->new; $mw->minsize(300, 250); my $entered; my $entry = $mw->Entry( -textvariable => \$entered, -width => 75, -tak +efocus => 1 )->pack(); $entry->focus( -force ); open (OUT, ">>:encoding(UTF-8)", "_entered.txt"); my $go = sub { print OUT "$entered\n"; }; my $buttgo = $mw -> Button( -text=>"Go", -command => $go ) -> pack(); $mw->bind( '<Return>', $go ); my $buttexit = $mw -> Button( -text=>"Exit", -command => sub {exit}, ) -> pack(); Tk::MainLoop();

And here's the exe from the same script: https://www.dropbox.com/s/dyxir5rd4et0fj7/entry.exe