Re: String Encocoding in Gtk-Perl: Hoping for Clarification

On Sat, May 8, 2010 at 7:42 PM, Peter Daum <gator_ml yahoo de> wrote:

Using some little test programs, I verified, that Gtk2 still returns
everything in utf8, so the change must be somewhere in Gtk2-Perl or in
Perl. When I run the following code snippet:
Gtk2-Perl also returns all strings in UTF-8. If you want to see if a string is in UTF-8 or not I suggest that you use Devel::Peek [1]
my $button = new Gtk2::Button( "print" );
my $entry Â= new Gtk2::Entry;
$button->signal_connect( "clicked",sub {print $entry->get_text,"\n"} );
ÂI'm certain that $entry->get_text returns an UTF-8 string. I'm guessing that the problem lies on the encoding of STDOUT. You should set explicitly the encoding of the STDOUT otherwise you can endup with broken characters on the console.

Try to set encoding of STDOUT to UTF-8. You can do this with:
ÂÂÂ binmode STDOUT, ":utf8";

or with the pragma open, which will change STDOUT, STDERR and STDIN:
ÂÂÂ use open ":utf8", ":std";

Emmanuel Rodriguez

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]