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;
| [reply] [d/l] |
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
| [reply] [d/l] |
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?
| [reply] |
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...
| [reply] [d/l] [select] |