lib/PublicInbox/NNTP.pm | 4 ++++ diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index d177bdc4b2a98cfe9b897869d57deee56debc1cb..a6321489e7142325ba7578eba08e64e365144688 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -16,6 +16,8 @@ use Data::Dumper qw(Dumper); use POSIX qw(strftime); use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); use URI::Escape qw(uri_escape_utf8); +use Encode qw(find_encoding); +my $enc_utf8 = find_encoding('UTF-8'); use constant { r501 => '501 command syntax error', r221 => '221 Header follows', @@ -900,6 +902,7 @@ } sub res ($$) { my ($self, $line) = @_; + $line = $enc_utf8->encode($line); do_write($self, $line . "\r\n"); } @@ -934,6 +937,7 @@ use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0; sub do_more ($$) { my ($self, $data) = @_; + $data = $enc_utf8->encode($data); if (MSG_MORE && !$self->{write_buf_size}) { my $n = send($self->{sock}, $data, MSG_MORE); if (defined $n) {