in reply to Re: Perl TK character disappearingue
in thread Perl TK character disappearing

Thanks! use UTF8 doesn't help, and I've added sample code to the original post...The output has an invisible character where the ASCII French character should be...

Replies are listed 'Best First'.
Re^3: Perl TK character disappearingue
by zentara (Cardinal) on Jun 27, 2012 at 17:21 UTC
    Hi, I hit a temporary glitch, then this started working for me. I don't know what to tell you. I suspect you have file encoding mismatches somewhere. When I download your code example, the œ dosn't show up in my editor or Tk. I then manually copy&pasted in œ from your html into the Tk program and it ran. Maybe some unicode guru knows the reason?
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::TextUndo; use utf8; my $main = MainWindow->new; my $middle = $main->Frame(-borderwidth=>2,-relief=>'groove')->grid(-ro +w=>0,-column=>1,-sticky=>'nsew'); my $middlebox = $middle->TextUndo ( -font => 'arial 20', -wrap => 'word', -spacing2 => 10, -spacing3 => 30, -takefocus => 1, -background => 'white', -width => 70, -height => 10, )->grid(-row=>0, -column=>0, -sticky=>'nsew +'); $middlebox->insert('end',"This is a test of the œ character\n"); print ord('œ'),"\n"; # prints 339 print chr(339),"\n"; $middlebox->insert('end', ord('œ') ); $middlebox->insert('end',"\n"); $middlebox->insert('end', chr(339) ); MainLoop;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      Well, you don't get utf from perlmonks, you get latin-1 or some such, and œ comes back as hex 9C

      If you add use utf8; at the bottom of the program it won't display right :) you have to add it to the top

        That explains the weirdness I saw, but how would you suggest the OP solve the original problem? Also, do you mean that "use utf8" must be listed first in the "use" list?

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh

      Very odd...I pasted your code in from the web, ran, and I get this output:

      This is a test of the 0 œ

      ...and the following errors in my command window...

      Malformed UTF-8 error...(2 times, lines 24 and 26) Wide character in print at....line 27 Malformed UTF-8 error...at line 29

      I'm wondering if this is getting down to different systems...I'm on Windows 7...