Home > Archive > PerlTk > October 2005 > PerlTK vs Perl on UTF-8 (displaying Chinese)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
PerlTK vs Perl on UTF-8 (displaying Chinese)
|
|
|
| Hi,
I am taking over a application using perlTK for GUI version and perl
for command-line version. I'm trying to display some Chinese messages
(read from a catelog file) but having trouble with the following
scenario (1 or 2):
1. Command-line version presents all messages correctly, but the perlTK
version does not;
2. If I use Pragma "use utf8" and save the message file in "utf-8"
format, then the perlTK version display those chinese correctly, but
the Command-line version does not work anymore.
It seems to me that perl and perlTK work differently from internal, but
I have no much clue on why.
Thank you so much in advance for any help.
Tom
| |
| ken.prows@online-rewards.com 2005-09-27, 6:59 pm |
| Does your command line support utf-8? It probably does, but I need to
ask. It *could* be that your command line supports a chinese character
set but not utf-8. Since Tk requires the charset to be utf-8, this
would explain the problem.
Are you using Linux, Windows, or..?
A little side note:
When working with utf-8, it is always best to make sure the utf-8 bit
is set. This has solved many of my utf-8 problems. This code snipet
will do just that:
utf8::decode($string) unless utf8::is_utf8($string);
-Ken
| |
|
| Thanks for your comments.
I should've said earlier that my OS is Simplified-chinese XP. But I
really don't know if the command-line supports utf-8 or not (or it may
use local code page, which is chinese).
Can I assume that to make both versions working, I have to convert all
non-utf-8 strings to feed perl/tk to be able to display. For the
command-line, no changes required since it uses local codepage
(non-utf-8).
Thanks
| |
| zentara 2005-09-28, 8:06 am |
| On 27 Sep 2005 04:27:47 -0700, "Tom" <tao.sunrise@gmail.com> wrote:
>Hi,
>I am taking over a application using perlTK for GUI version and perl
>for command-line version. I'm trying to display some Chinese messages
>(read from a catelog file) but having trouble with the following
>scenario (1 or 2):
>
>1. Command-line version presents all messages correctly, but the perlTK
>version does not;
>
>2. If I use Pragma "use utf8" and save the message file in "utf-8"
>format, then the perlTK version display those chinese correctly, but
>the Command-line version does not work anymore.
>
>It seems to me that perl and perlTK work differently from internal, but
>I have no much clue on why.
>
>Thank you so much in advance for any help.
A similar tricky problem was asked here awhile back. I don't know if
this will address your problem exactly, but it may help.
http://perlmonks.org/index.pl? repl...d=4758
26
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
| |
|
| Thanks for the help. It seems working now with the manual conversion
from local codepage to utf8, back and forth. The bottom line is perl/tk
does not support utf8 automatically.
|
|
|
|
|