Skip to content

Gibberish displayed when content has unicode, can an option be added to control utf8 flag into Log::Dispatch ? #38

@hadjiprocopis

Description

@hadjiprocopis

I get gibberish on my console when running the following, with or without binmode'ing STDERR:

use LWP::UserAgent;
use LWP::ConsoleLogger::Easy qw( debug_ua );

# gibberish with or without it
#binmode STDERR, ':encoding(UTF-8)';

my $ua = LWP::UserAgent->new();
my $logger = debug_ua($ua, 5);
# greek content
#my $res = $ua->get('https://tvxs.gr');
my $res = $ua->get('https://www.greekfontsociety-gfs.gr/about');

What works for me (well ok I get question-marks for a few characters) is to tell $logger to use a new Log::Dispatch with the utf8 flag turned off, as follows:

use LWP::UserAgent;
use LWP::ConsoleLogger::Easy qw( debug_ua );
use Log::Dispatch;

my $ua = LWP::UserAgent->new();
my $logger = debug_ua($ua, 5);

$logger->logger(Log::Dispatch->new(
  outputs => [
    [ 'Screen', min_level => 'debug', newline => 1, utf8 => 0, ],
  ],
));
 
# greek content
#my $res = $ua->get('https://tvxs.gr');
my $res = $ua->get('https://www.greekfontsociety-gfs.gr/about');

Is there a simpler way to display the unicode content correctly?

Or can you allow controlling utf8 via LWP::ConsoleLogger::Easy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions