GMimeFilterBest

GMimeFilterBest — Determine the best charset/encoding to use for a stream

Functions

Types and Values

Description

A GMimeFilter which is meant to determine the best charset and/or transfer encoding suitable for the stream which is filtered through it.

Encoding detection follows MimeKit's BestEncodingFilter. It preserves input bytes and tracks line lengths across buffers, excluding the CRLF terminator. The default maximum line length is 78; use g_mime_filter_best_encoding_with_max_line_length() to select another limit.

Functions

g_mime_filter_best_new ()

GMimeFilter *
g_mime_filter_best_new (GMimeFilterBestFlags flags);

Creates a new GMimeFilterBest filter. flags are used to determine which information to keep statistics of. If the GMIME_FILTER_BEST_CHARSET bit is set, the filter will be able to compute the best charset for encoding the stream of data filtered. If the GMIME_FILTER_BEST_ENCODING bit is set, the filter will be able to compute the best Content-Transfer-Encoding for use with the stream being filtered.

Note: In order for the g_mime_filter_best_charset() function to work, the stream being filtered MUST already be encoded in UTF-8.

Parameters

flags

filter flags

 

Returns

a new best filter with flags flags .


g_mime_filter_best_charset ()

const char *
g_mime_filter_best_charset (GMimeFilterBest *best);

Calculates the best charset for encoding the content filtered through the best filter.

Parameters

best

a GMimeFilterBest

 

Returns

the name of the charset most suitable for encoding the content that has been passed through the filter or NULL if the filter was not configured to detect this.


g_mime_filter_best_encoding ()

GMimeContentEncoding
g_mime_filter_best_encoding (GMimeFilterBest *best,
                             GMimeEncodingConstraint constraint);

Calculates the most efficient Content-Transfer-Encoding for the content filtered through best that fits within the encoding constraint , using a maximum line length of 78 excluding CRLF.

This is equivalent to calling g_mime_filter_best_encoding_with_max_line_length() with a limit of 78.

Parameters

best

a GMimeFilterBest

 

constraint

a GMimeEncodingConstraint

 

Returns

the best encoding for the content filtered by best .


g_mime_filter_best_encoding_with_max_line_length ()

GMimeContentEncoding
g_mime_filter_best_encoding_with_max_line_length
                               (GMimeFilterBest *best,
                                GMimeEncodingConstraint constraint,
                                guint max_line_length);

Selects a transfer encoding using MimeKit's best-encoding rules. NUL bytes, high-bit byte density, long lines, and lines beginning with "From " affect the choice. The binary constraint permits binary data but still selects base64 or quoted-printable for long or From-lines.

The current unterminated line is included without requiring completion. Calling this function does not change the filter state. ASCII content requiring no encoding returns GMIME_CONTENT_ENCODING_7BIT. If encoding detection is disabled, returns GMIME_CONTENT_ENCODING_UNSPECIFIED.

Parameters

best

a GMimeFilterBest

 

constraint

a GMimeEncodingConstraint

 

max_line_length

maximum line length, excluding CRLF, from 60 through 998

 

Returns

the best encoding for the content filtered by best .

Types and Values

GMimeFilterBest

typedef struct _GMimeFilterBest GMimeFilterBest;

A filter for calculating the best encoding and/or charset to encode the data passed through it.


enum GMimeFilterBestFlags

Bit flags to enable charset and/or encoding scanning to make educated guesses as to what the best charset and/or encodings to use for the content passed through the filter.

Members

GMIME_FILTER_BEST_CHARSET

Enable best-charset detection.

 

GMIME_FILTER_BEST_ENCODING

Enable best-encoding detection.

 

See Also

GMimeFilter