C-escape

From Mailutils
Revision as of 08:10, 23 March 2011 by Gray (talk | contribs) (Created page with "The ''C-escape'' filter replaces C escape sequences with the corresponding control character and vice versa. In encode mode, recognized control characters are replaced with...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The C-escape filter replaces C escape sequences with the corresponding control character and vice versa.

In encode mode, recognized control characters are replaced with their C escapes. For example, newline (ASCII 10) becomes \n, horizontal tab (ASCII 9) becomes \t, etc.

In decode mode, the reverse operation is performed, i.e. each C escape is replaced with the corresponding character. Unrecognized escape sequences are copied verbatim.

Only named escapes are supported, i.e.: \\, \a, \b, \f, \n, \r, \t, \v.

This filter does not take arguments.

The following object, declared in mailutils/filter.h describes the C-escape filter:

extern mu_filter_record_t mu_c_escape_filter;

The example below shows how to create an instance of this filter in decode mode for reading:

  int rc;          /* Return code */
  mu_stream_t flt; /* Filter stream */
  mu_stream_t input; /* Input stream */
 
  initialize_input_stream (&stream);
  rc = mu_filter_stream_create (&flt, input, "C-escape", MU_FILTER_DECODE, MU_STREAM_READ);