| Top |
Previewers produce UTF-8 plain text with collapsed whitespace and a configurable length limit measured in Unicode scalar values. The HTML previewer requires an explicit body element; use GMimeHtmlToText to render arbitrary HTML fragments.
GMimeTextFormat
g_mime_text_previewer_get_input_format
(GMimeTextPreviewer *previewer);
Gets the text format accepted by previewer
.
guint
g_mime_text_previewer_get_maximum_preview_length
(GMimeTextPreviewer *previewer);
Gets the maximum preview length, measured in Unicode scalar values rather than bytes or UTF-16 code units.
void g_mime_text_previewer_set_maximum_preview_length (GMimeTextPreviewer *previewer,guint maximum);
Sets the preview length limit. When text is truncated, the last output character is replaced by an ellipsis, which counts toward this limit.
char * g_mime_text_previewer_get_preview_text (GMimeTextPreviewer *previewer,const char *text,GError **error);
Generates a plain-text preview with collapsed whitespace. Plain-text
string previews treat U+200B through U+200D as whitespace; plain-text
stream previews preserve those characters. The returned string must
be freed with g_free().
char * g_mime_text_previewer_get_preview_text_from_stream (GMimeTextPreviewer *previewer,GMimeStream *stream,const char *charset,GError **error);
Generates a UTF-8 plain-text preview from stream
using charset
for
decoding. Unrecognized charsets fall back to UTF-8; byte-order-mark
detection is not performed. Invalid input encountered while decoding
and stream I/O failures are reported through error
.
Reading can stop once the preview is full, but buffering may consume
additional input. The caller's stream is not reset or closed. The
returned string must be freed with g_free().
char * g_mime_text_previewer_get_preview_text_from_part (GMimeTextPart *part,GError **error);
Reads at most 16 KiB of transfer-decoded content and applies GMimeTextPart's charset, byte-order-mark and fallback decoding. Format=flowed text is unwrapped using the part's delsp parameter. HTML parts use an HTML previewer; other text parts use a plain-text previewer. The default maximum preview length of 230 Unicode scalar values is used.
A part without content produces an empty string. The returned string
must be freed with g_free().
GMimeTextPreviewer *
g_mime_plain_text_previewer_new (void);
Creates a plain-text previewer that collapses whitespace and produces previews of at most 230 Unicode scalar values by default.
GMimeTextPreviewer *
g_mime_html_text_previewer_new (void);
Creates an HTML previewer that extracts text from an explicit body element, suppresses script/style and structural list/table text, and prefixes ordered list items. The default preview length is 230 Unicode scalar values.
Input without a body element produces an empty preview. Use GMimeHtmlToText to render arbitrary HTML fragments.
typedef struct _GMimeTextPreviewer GMimeTextPreviewer;
An abstract generator of bounded, plain-text previews.
struct GMimeTextPreviewerClass {
GObjectClass parent_class;
GMimeTextFormat input_format;
char *(*preview) (GMimeTextPreviewer *previewer, GMimeStream *input, gboolean string_input, GError **error);
};
Base class for text previewers. Implementations must not retain or close
the input stream and must return NULL on failure.
GMimeTextFormat |
the text format accepted by the previewer |
|
generates an allocated UTF-8 preview from a UTF-8 stream; the string_input argument distinguishes string and stream whitespace handling; reports failures through its error argument |
typedef struct _GMimePlainTextPreviewer GMimePlainTextPreviewer;
Generates plain-text previews with collapsed whitespace.