Hi,

I understand a bit about how encoded email data works, but I'm far from an expert. I'm stumped on a problem that just started occurring for one of our customers. My script isn't able to parse quoted-printable, euc-jp mail subjects. It does fine with other asian charsets + quoted-printable, and also with euc-jp base64 data.

The data that I have is a little fishy looking to me, and I'm wondering if someone can offer any insight into what's different between my working and non-working strings below, and/or advice on how to decode the non-working string.

use strict; use warnings; use Encode; for my $subject ( # bad: '=?euc-jp?Q?=83v=83=8D=83t=83B=81=5B=83=8B?=', # bad: '=?euc-jp?Q?=97L=97=BF=83T=81=5B=83r=83X?=', # good: '=?euc-jp?Q?=B2=F1=B0=F7=CD=CD=A4=D8=C9=AC=A4=BA=C5=F +6=A4=EB?=', ) { print "\ndecoding $subject ...\n"; my $decoded = Encode::decode('MIME-Header',$subject); print "result: $decoded\n"; } __END__ decoding =?euc-jp?Q?=83v=83=8D=83t=83B=81=5B=83=8B?= ... result: \x83v\x83\x8D\x83t\x83B\x81[\x83\x8B decoding =?euc-jp?Q?=97L=97=BF=83T=81=5B=83r=83X?= ... result: \x97L\x97\xBF\x83T\x81[\x83r\x83X decoding =?euc-jp?Q?=B2=F1=B0=F7=CD=CD=A4=D8=C9=AC=A4=BA=C5=F6=A4=EB?= + ... Wide character in print at ./test line 15. result: [something that looks like "correct" garbled text in my shell +]

The thing that looks strange about the bad strings is the alternation of "=xx" with single ascii characters. I think technically that's valid quoted-printable, but usually I just see the repeated "equals sign plus 2 hex chars" like in the good string above.

Also, when I bounce this mail to my outlook, it shows the subject correctly.

Any advice?

Thanks,
Joe


In reply to problem decoding a quoted-printable euc-jp mail header by blahblahblah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.