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


in reply to Odd encoding problem in Tk app when packaged with pp

It works for me on Linux:
#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = Tk::MainWindow->new; $mw->minsize( 300, 250 ); my $entered = "\x{171}"; open OUT, '>>', $entered; binmode OUT, ":encoding(UTF-8)"; my $entry = $mw->Entry( -textvariable => \$entered, -width => 75, -takefocus => 1, )->pack(); $entry->focus( -force ); 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(); close OUT; Tk::MainLoop();

Replies are listed 'Best First'.
Re^2: Odd encoding problem in Tk app when packaged with pp
by elef (Friar) on Jan 28, 2013 at 10:49 UTC
    Well, it works for me on Windows, too. I'm only getting a bug when packaging the script with PAR::Packer, and even then only when typing into the box, not when copy-pasting into it or hardcoding the funky characters into the script.