I think the problem may be that you are actually dealing with two different encodings for Japanese. If the first two examples in your list were identified as "shiftjis" instead of "euc-jp", they would produce valid Japanese characters rather than gibberish. (Whether they produce coherent, meaningful Japanese subject lines is another matter, and I'm sorry I can't help you there.)

As for the third example, euc-jp works correctly for that, and changing its label to shiftjis causes it to come out as gibberish.

If I understand the docs I've seen, shiftjis is a system that uses one byte per character for ASCII content, and two bytes per character for Japanese, where the first byte of a Japanese pair always has the eigth bit set, and the second byte may or may not have the eigth bit set.

Meanwhile, euc-jp uses a different strategy to allow ASCII and Japanese content to coexist: ASCII content is again one byte per character, but Japanese content may be two or three bytes per character, and all bytes of a Japanese character must have the eigth bit set.

Since your first two strings appear to be composed of byte pairs with the second byte sometimes in the ASCII range, they cannot be valid euc-jp. They'll display nicely if treated as shiftjis (and then if they make sense to people who know Japanese, so much the better).

As for your finding that they all display correctly in Outlook... euc-jp comes from the unix world, whereas shiftjis is more in the MS-Windows domain. I guess I wouldn't be surprised to learn that MS software somehow manages to ignore an incorrect encoding label.

So where are those labels coming from, anyway? Is someone sending you bad data, or are you creating bad data?


In reply to Re: problem decoding a quoted-printable euc-jp mail header by graff
in thread 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.