GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Sieve Language   Up: Extensions   FastForward: Reporting Bugs   Contents: Table of ContentsIndex: Function Index

5.8.1 The encoded-character extension

The ‘encoded-character’ extension complies with RFC 5228, part 2.4.2.4. It provides a way of incorporating multibyte sequences in a Sieve script using only ASCII characters. This is a built-in extension. It is enabled using the following statement:

require "encoded-character";

When this extension is enabled, the sequences ‘${hex: ...}’, and ‘${unicode: ...}’ can appear inside of quoted strings.

The sequence

${hex: XX}

where XX is a sequence of one or two-digit hex numbers separated by any amount of whitespace, is replaced with the octets with the hexadecimal values given by each hex number. For example,

"${hex: 24 24}" ⇒ "$$"

Thus, the following script will discard any message containing three contiguous dollar signs in its ‘Subject’ header:

require "encoded-character";

if header :contains "Subject" "$${hex:24 24}" {
     discard;
}

The ‘hex:’ keyword is case-insensitive. If XX contains invalid hex numbers, the entire sequence is left verbatim. This is illustrated by the following example:

"$${hex:40}"         ⇒ "$@"
"${hex: 40 }"        ⇒ "@"
"${HEX: 40}"         ⇒ "@"
"${hex:40"             ⇒ "${hex:40"
"${hex:400}"         ⇒ "${hex:400}"
"${hex:4${hex:30}}"  ⇒ "${hex:40}"

The sequence

${unicode: HEXNUM}

where HEXNUM is a list of hexadecimal numbers separated with whitespace, will be replaced by the UTF-8 encoding of the specified Unicode characters, which are identified by the hexadecimal value of HEXNUM. For example, the following string represents a single ‘@’ sign:

"${UNICODE:40}"

Similarly to ‘hex:’, the ‘unicode:’ indicator is case insensitive. The following examples demonstrate the handling of several valid and invalid encodings:

"${unicode:40}"      ⇒ "@"
"${ unicode:40}"     ⇒ "${ unicode:40}"
"${UNICODE:40}"      ⇒ "@"
"${UnICoDE:0000040}" ⇒ "@"
"${Unicode:40}"      ⇒ "@"
"${Unicode:Cool}"    ⇒ "${Unicode:Cool}"
"${unicode:200000}"  ⇒ error
"${Unicode:DF01}     ⇒ error

GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Sieve Language   Up: Extensions   FastForward: Reporting Bugs   Contents: Table of ContentsIndex: Function Index