Perl and Gtk2 與中文

趁著還記得趕快記下來^^
Perl的encode轉換做的很不錯喔~~~
Gtk2是吃utf8的,透過轉換可以很方便的使用中文

這是我寫的範例…

#!/usr/bin/perl -w
use strict;
use Gtk2;
use encoding "Big5",STDOUT=>"utf8";

Gtk2->init;
my $title = "Hello 2 !";
my $win = Gtk2::Window->new ("toplevel");
$win->set_title ($title);
$win->set_default_size (200,200);
$win->signal_connect("delete_event",sub { Gtk2->main_quit;});

my $vbox = Gtk2::VBox->new (0, 0);
$win->add ($vbox);

my $str = <<HERE;

測試	測試
哈哈
Perl is very good ^^

HERE
my $label = Gtk2::Label->new ($str);
$vbox->pack_start ($label,1 ,1 ,0);

$win->show_all;
Gtk2->main;