Octavian Rasnita wrote:

I've just installed the editor Padre using cpan, and I have tried to run the following script:

use utf8;

binmode STDOUT, ":utf8";

print "ţâţă de mâţă";

#But when running the program with F5 it prints:
ţâţă de mâţă

...instead of those UTF-8 chars.

Can I do something to make it print the correct chars?

Quick disclaimer: I have nothing to do with this project.

I took a quick look and found the problem: Padre runs your script as a process and gets back the process's STDOUT, but Padre doesn't know or care that your script was printing in utf8 - it just treats it as a bunch of bytes.

I was able to fix it by adding the following code to Padre/Wx/Output.pm:

use Encode;
sub AppendText {
        my ($self, $text) = @_;
        my $string = decode("utf8", $text);
        $self->SUPER::AppendText($string);
}

This could (and should) be extended to allow any encoding in the output window. Perhaps I'll do that next week, and submit a patch to the Padre team.

Reply via email to