Why does Term::Size seem to mess up Perl's output encoding?

Posted by sid_com on Stack Overflow See other posts from Stack Overflow or by sid_com
Published on 2010-03-21T13:48:48Z Indexed on 2010/05/17 13:10 UTC
Read the original article Hit count: 164

Filed under:
|
|

Hello! The Term::Size-module jumbles up the encoding. How can I fix this?

#!/usr/bin/env perl
use warnings; use strict;
use 5.010;
use utf8;
binmode STDOUT, ':encoding(UTF-8)';
use Term::Size;

my $string = 'Hällö';
say $string;

my $columns = ( Term::Size::chars *STDOUT{IO} )[0];

say $columns;
say $string;

Output:

Hällö
140
H?ll?

© Stack Overflow or respective owner

Related posts about perl

Related posts about encoding