in reply to Re: Putting a utf-8 subject into a mail header
in thread Putting a utf-8 subject into a mail header

I tried it in the decode script and got

Unknown PerlIO layer "UTF8" at /home/talexb/bin/decode line 17.
Is there somewhere else that you think the case of 'utf' matters?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^3: Putting a utf-8 subject into a mail header
by Anonymous Monk on Feb 27, 2009 at 15:45 UTC
    Sorry, i was thinking
    binmode STDOUT, ':encoding(UTF-8)';
    might make a difference, but you need
    encode("MIME-Header",decode('UTF-8',$arg)));

      Wow. It works. I'm not sure I understand, but I'll save that for later.

      Thank you. :)

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        See Encode::MIME::Header for a further explanation. Also, RFC 2047 has the exact format and even a rationale for why it has to be encoded differently from the MIME email body.

        The biggest concerns are, BTW, a lack of information during processing of the headers and backwards compatibility with systems that only support 7bit encoding for headers. It's a header that tells what kind of MIME encoding the body will use. If your headers are encoded using the same method, you have a chicken-and-egg problem. RFC 2047 gives a 7-bit clean escape sequence to state the encoding in the individual header, and both servers and clients expect this method of escaping for non-7bit headers.

        This is a bit of a messy workaround, but it allows your MIME-encoded email with MIME-encoded headers to pass cleanly through SMTP servers that know nothing of these RFCs and be handled properly by the sending and receiving clients anyway.

Re^3: Putting a utf-8 subject into a mail header
by almut (Canon) on Feb 27, 2009 at 15:57 UTC

    To expand on what Anonymous Monk said, @ARGV is one of those things in Perl (like filenames), where Unicode isn't handled automatically, so you need to explicitly decode your input.

      I thought I read yesterday in the Camel that @ARGV *did* handle utf-8, otherwise I would have pursued that possibility. Now, of course, I can't find the page that I thought I read. In my case, the input's coming from a web form .. so I may need to do the same thing for another problem I'm having.

      It would be awesome if this solution solves that problem as well. :)

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      or add
      #!/usr/bin/perl -CDSLA
      -C is -CDSL