From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.3 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5982220D59; Fri, 13 May 2016 12:17:54 +0000 (UTC) Date: Fri, 13 May 2016 12:17:54 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] nntp: fixup "Wide character" warnings Message-ID: <20160513121754.GA2685@dcvr.yhbt.net> References: <20160513113736.19907-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160513113736.19907-1-e@80x24.org> List-Id: We need Perl to believe everything we send is UTF-8, make it so, even if it may not be. Fixes: 265e79ff82ce 'Revert "nntp: proper UTF-8 support (hopefully?)"' --- lib/PublicInbox/NNTP.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index d177bdc..a632148 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 cmd_xpath ($$) { 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) {