about summary refs log tree commit homepage
path: root/lib/PublicInbox/Eml.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Eml.pm')
-rw-r--r--lib/PublicInbox/Eml.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm
index ec682b91..1fecd41b 100644
--- a/lib/PublicInbox/Eml.pm
+++ b/lib/PublicInbox/Eml.pm
@@ -368,9 +368,12 @@ sub header_str_set {
         my ($self, $name, @vals) = @_;
         for (@vals) {
                 next unless /[^\x20-\x7e]/;
-                utf8::encode($_); # to octets
                 # 39: int((75 - length("Subject: =?UTF-8?B?".'?=') ) / 4) * 3;
-                s/(.{1,39})/'=?UTF-8?B?'.encode_base64($1, '').'?='/ges;
+                s/(.{1,39})/
+                        my $x = $1;
+                        utf8::encode($x); # to octets
+                        '=?UTF-8?B?'.encode_base64($x, '').'?='
+                /xges;
         }
         header_set($self, $name, @vals);
 }