Subject: | MIME header encodings handle trailing newlines inconsistently |
This is not a bug but an inconsistency of feature between ISO_2022_JP
and other variants of MIME-Header encodings.
MIME-(B|Q|Header) eat trailing newlines of string to be encode()'ed.
On the other hand, MIME-Header-ISO_2022_JP seems to shorten trailing
newlines.
I checked Encode 2.39 with Perl 5.12.3. Earlier versions might be able
to reproduce this behavior.
Test code:
---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----
use utf8;
use Encode::MIME::Header;
use Encode qw(encode);
my $str = "Subject: ……以後、コードを書くことは野蛮である\n\n";
foreach (qw(UTF-8 MIME-B MIME-Q MIME-Header-ISO_2022_JP)) {
print "<".encode($_, $str).">\n";
}
---- >8 ---- >8 ---- >8 ---- >8 ---- >8 ---- >8 ---- >8 ---- >8 ---- >8 ----
Result:
============================================================================
<Subject: ……以後、コードを書くことは野蛮である
Show quoted text
>
<Subject:
=?UTF-8?B?IOKApuKApuS7peW+jOOAgeOCs+ODvOODieOCkuabuOOBj+OBk+OBqOOBr+mHjg==?=
=?UTF-8?B?6Juu44Gn44GC44KL?=>
<Subject:
=?UTF-8?Q?=20=E2=80=A6=E2=80=A6=E4=BB=A5=E5=BE=8C=E3=80=81=E3=82=B3?=
=?UTF-8?Q?=E3=83=BC=E3=83=89=E3=82=92=E6=9B=B8=E3=81=8F=E3=81=93=E3=81=A8?=
=?UTF-8?Q?=E3=81=AF=E9=87=8E=E8=9B=AE=E3=81=A7=E3=81=82=E3=82=8B?=>
<Subject: =?ISO-2022-JP?B?GyRCIUQhRDBKOGUhIiUzITwlSSRyPXEkLyQzJEgkT0xuGyhC?=
=?ISO-2022-JP?B?GyRCSFokRyQiJGsbKEI=?=
Show quoted text>
============================================================================
Thanks.