C-escape

From Mailutils
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 (&input);
  rc = mu_filter_create (&flt, input, "C-escape", MU_FILTER_DECODE, MU_STREAM_READ);