Next: , Previous: , Up: Library   [Contents][Index]


5.14 Mail Header Functions

Built-in Function: string message_header_encode (string text, [string enc, string charset])

Encode text in accordance with RFC 2047. Optional arguments:

enc

Encoding to use. Valid values are ‘quoted-printable’, or ‘Q’ (the default) and ‘base64’, or ‘B’.

charset

Character set. By default ‘UTF-8’.

If the function is unable to encode the string, it raises the exception e_failure.

For example:

set string "Keld Jørn Simonsen <keld@dkuug.dk>"
message_header_encode(string, "ISO-8859-1")
  ⇒ "=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>"
Built-in Function: string message_header_decode (string text, [string charset])

text must be a header value encoded in accordance with RFC 2047. The function returns the decoded string. If the decoding fails, it raises e_failure exception. The optional argument charset specifies the character set to use (default – ‘UTF-8’).

set string "=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>"
message_header_decode(string)
 ⇒ "Keld Jørn Simonsen <keld@dkuug.dk>"
Built-in Function: string unfold (string text)

If text is a “folded” multi-line RFC 2822 header value, unfold it. If text is a single-line string, return its unchanged copy.

For example, suppose that the message being processed contained the following header:

List-Id: Sent bugreports to
  <some-address@some.net>

Then, applying unfold to its value24 will produce:

Sent bugreports to <some-address@some.net>

Footnotes

(24)

For example:

prog header
do
  echo unfold($2)
done