procmail
[Top] [All Lists]

Re: How to avoid s/\n/ /g when unfolding a header

2004-12-13 16:29:34
Toen wij Robert Allerstorfer kietelden, kwam er dit uit:

The next step is to delete all \n. Can this also done with sed?

  http://go.to/sed-faq 3.2
  # If a line begins with an equal sign, append it to the previous
  # line (and replace the "=" with a single space).
  sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D' file

One (portable) way to use that technique is

  sed -e :a -e '$!N; s/\n[  ][  ]*/ /; ta' -e 'P;D'

where each [  ] contains a space and a tab.

This will leave any whitespace at the end of a line, replace each
newline
with a single space, and skip all whitespace that is at the start of
a continuation line.

This could of course be rewritten to not insert a space when the first
line already ends in whitespace, but I wouldn't.



But see also the examples in section 8 of RFC 2047
  http://www.faqs.org/rfcs/rfc2047.html

"White space between adjacent encoded-word's is not displayed."

And in Q-encoding, a space may be represented as "_" (underscore).

-- 
Grtz, Ruud


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail