Here's a tiny complete app which demonstrates the problem:
#!/usr/bin/perl -w
use Tk;
use strict;
my ($mw, $test_string, $txt);
$mw = MainWindow->new(-title => "UTF-8 Test", -width=>400, -height=>30
+0);
$test_string = 'This is a sample Chinese character: 我';
$txt = $mw->Text(-height=>5)->pack;
$txt->insert('end', $test_string);
MainLoop;
The entity in the code above was inserted by the PerlMonks web site. In my original source code I have a Chinese character. If anyone wants to try out this issue, you'll have to somehow get a Unicode character into the string.
--- Marais
Update: Oh boy, life is complicated. I now find that this code, designed to demonstrate the problem, actually works IF you use this:
$test_string = 'This is a sample Chinese character: ' . chr(25105);
and it also works with the original Chinese character if I include
use utf8;
So clearly I have to give this some more thought. It's looking as if a string retrieved from the database must be different in some important way from a constant string. Gack.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.