cmv has asked for the wisdom of the Perl Monks concerning the following question:
I have users who are doing cut-n-paste into a Tk Entry widget in my perl app and causing some issues.
Apparently things like Outlook, Notepad, etc, can be configured to change an ASCII single quote (') into smart quotes aka Unicode Right Single Quote and Left Single Quote. When they cut-n-paste this into my entry widget, I see goofy things happen later in my script. I'm including a test script below, note the difference between what shows up in the message box and what the print STDERR outputs.
What is going on here, and what are some intelligent ways for me to handle it?
I think I want to simply translate any unicode single quotes (left or right) to the ASCII single quote - no? What if they start pasting other unicode characters? Looking for experience & guidance here.
Thanks
-Craig
#!/opt/homebrew/bin/perl use strict; use warnings; use Tk; my $main = new Tk::MainWindow(); my $entry_test = $main->Entry(-text => "single-quotes: ’'")->pack(); my $btn_test = $main->Button( -text => ' Test ', -command => sub { my $text = $entry_test- +>get(); &msg($main, $text) if ( +$text); } )->pack(); sub msg { my ($parent, $msg) = @_; print STDERR "Messaging: $msg\n"; $parent->messageBox( -title => 'Event', -message => $msg, -type => ' +ok', -icon => 'info' ); } MainLoop();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Tk Entry & Right Single Quote
by choroba (Cardinal) on Apr 11, 2024 at 23:34 UTC | |
by Marshall (Canon) on Apr 13, 2024 at 02:09 UTC | |
by cmv (Chaplain) on Apr 13, 2024 at 22:39 UTC | |
Re: Tk Entry & Right Single Quote
by NERDVANA (Priest) on Apr 12, 2024 at 07:22 UTC | |
by cmv (Chaplain) on Apr 13, 2024 at 22:46 UTC | |
My Solution: Tk Entry & Right Single Quote
by cmv (Chaplain) on Apr 15, 2024 at 22:37 UTC | |
by cmv (Chaplain) on Apr 24, 2024 at 20:48 UTC |