in reply to Perl TK character disappearing

Try putting "use utf8;" in your program, or show us a simple running code example.

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

Replies are listed 'Best First'.
Re^2: Perl TK character disappearingue
by cr8josh (Sexton) on Jun 27, 2012 at 15:55 UTC

    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...

      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

        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...