From 54c10e3aac3020b83a3be0b9578894154bd3de6a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Dec 2015 02:30:28 +0000 Subject: hval: introduce new_bin for raw data Since we no longer get our data from Email::MIME when reading non-email, we need to explicitly specify it as such. --- lib/PublicInbox/Hval.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/PublicInbox/Hval.pm') diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index 70bae7c6..2e8b1d60 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -18,8 +18,19 @@ our @EXPORT_OK = qw/ascii_html/; use constant STYLE => ''; use constant PRE => ""; # legacy +my $enc_utf8 = find_encoding('UTF-8'); my $enc_ascii = find_encoding('us-ascii'); +sub new_bin { + my ($class, $raw, $href) = @_; + + $raw = $enc_utf8->decode($raw); + bless { + raw => $raw, + href => defined $href ? $href : $raw, + }, $class; +} + sub new { my ($class, $raw, $href) = @_; -- cgit v1.2.3-24-ge0c7