| Top |
| GMimeTextPart * | g_mime_text_part_new () |
| GMimeTextPart * | g_mime_text_part_new_with_subtype () |
| GMimeTextPart * | g_mime_text_part_new_with_format () |
| GMimeTextFormat | g_mime_text_part_get_format () |
| gboolean | g_mime_text_part_is_plain () |
| gboolean | g_mime_text_part_is_flowed () |
| gboolean | g_mime_text_part_is_html () |
| gboolean | g_mime_text_part_is_enriched () |
| gboolean | g_mime_text_part_is_rich_text () |
| const char * | g_mime_text_part_get_charset () |
| void | g_mime_text_part_set_charset () |
| gboolean | g_mime_text_part_try_detect_encoding () |
| char * | g_mime_text_part_get_text () |
| char * | g_mime_text_part_get_text_with_encoding () |
| void | g_mime_text_part_set_text () |
GMimeTextPart *
g_mime_text_part_new (void);
Creates a new text MIME part object with a default content-type of text/plain.
GMimeTextPart *
g_mime_text_part_new_with_subtype (const char *subtype);
Creates a new text MIME part with a sepcified subtype.
GMimeTextPart *
g_mime_text_part_new_with_format (GMimeTextFormat format);
Creates a text part for format
. Flowed text uses text/plain with a
format=flowed parameter. Both rich-text formats use text/rtf; this
constructor does not compress content.
GMimeTextFormat
g_mime_text_part_get_format (GMimeTextPart *mime_part);
Gets the format indicated by the Content-Type header. Unknown media
types and subtypes return GMIME_TEXT_FORMAT_PLAIN. Enriched text
includes text/richtext; RTF includes application/rtf.
Flowed text is text/plain with a format parameter equal to "flowed", ignoring ASCII case and surrounding ASCII linear whitespace in the parameter. Compressed rich text is not inferred from the Content-Type header.
gboolean
g_mime_text_part_is_plain (GMimeTextPart *mime_part);
Tests whether the Content-Type is text/plain, ignoring ASCII case. This also matches flowed text.
gboolean
g_mime_text_part_is_flowed (GMimeTextPart *mime_part);
Tests for text/plain with a format parameter equal to "flowed", ignoring ASCII case and surrounding ASCII linear whitespace.
gboolean
g_mime_text_part_is_html (GMimeTextPart *mime_part);
Tests whether the Content-Type is text/html, ignoring ASCII case.
gboolean
g_mime_text_part_is_enriched (GMimeTextPart *mime_part);
Tests whether the Content-Type is text/enriched or text/richtext, ignoring ASCII case.
gboolean
g_mime_text_part_is_rich_text (GMimeTextPart *mime_part);
Tests whether the Content-Type is text/rtf or application/rtf, ignoring ASCII case.
const char *
g_mime_text_part_get_charset (GMimeTextPart *mime_part);
Gets the value of the charset parameter on the Content-Type header.
void g_mime_text_part_set_charset (GMimeTextPart *mime_part,const char *charset);
Sets the charset parameter on the Content-Type header to the specified value.
gboolean g_mime_text_part_try_detect_encoding (GMimeTextPart *mime_part,char **charset,GMimeTextEncodingConfidence *confidence,GError **error);
Resolves the Content-Type charset, then looks for a UTF-8 or UTF-16 BOM in
transfer-decoded content. A supported declared charset takes precedence
over a BOM; either gives GMIME_TEXT_ENCODING_CONFIDENCE_CERTAIN. Missing,
invalid and unsupported declarations are ignored. No content gives
"us-ascii" with GMIME_TEXT_ENCODING_CONFIDENCE_IRRELEVANT, even if a charset
is declared. Empty content is not the same as absent content.
HTML without a declaration or BOM is scanned for meta charset declarations
in its first 1024 transfer-decoded bytes. A supported meta charset gives
GMIME_TEXT_ENCODING_CONFIDENCE_TENTATIVE. The scan requires opening html
and head tags and stops at a body tag. Both charset attributes and
http-equiv="Content-Type" declarations are recognized. Unsupported names
are skipped; x-user-defined maps to Windows-1252 and UTF-16 to UTF-8.
Otherwise returns FALSE with NULL charset
and
GMIME_TEXT_ENCODING_CONFIDENCE_UNDEFINED. This does not guess UTF-8 or
Latin-1 or validate the entire content.
A declared charset or absent content requires no I/O. Otherwise this opens
a decoded reader with g_mime_content_open() and makes one read of up to
three decoded bytes. The decoder may read ahead in the backing stream;
short BOM reads are not retried. The HTML scan opens a new decoded reader
and fills its bounded prefix across short reads. Readers are released
without closing or rewinding the backing stream. This path uses the backing
stream, not the content's decode-to-stream override. Source-backed content
must remain open and unchanged.
Stream failures report GMIME_ERROR; operational charset resolution
failures report G_CONVERT_ERROR. Both outputs are cleared on failure.
Neither headers nor content bytes are modified. Free charset
with g_free().
mime_part |
||
charset |
the detected charset, or |
[out][nullable][transfer full] |
confidence |
confidence in the detected charset. |
[out][optional] |
error |
return location for an error, or |
char *
g_mime_text_part_get_text (GMimeTextPart *mime_part);
Gets the text content of the mime_part
as a string.
Generic UTF-16 and UTF-32 charsets use little-endian bytes, matching
g_mime_text_part_set_text_with_charset().
char * g_mime_text_part_get_text_with_encoding (GMimeTextPart *mime_part,char **used_charset,GError **error);
Gets checked, automatically decoded UTF-8 text and optionally reports its
source charset. Uses the same decoding policy as
g_mime_message_get_text_body_with_format(): supported declared charsets and
UTF-16 BOMs use replacement, while UTF-8 BOMs and the UTF-8 default use
strict decoding and retry malformed input as ISO-8859-1. Without a declared
charset or BOM, HTML meta charsets in the first 1024 decoded bytes are used
before the UTF-8 default. Meta charsets use replacement, except UTF-16
declarations remapped to strict UTF-8. Incomplete final characters are
handled rather than dropped.
Reports the charset used by the successful conversion, including Latin-1
after fallback, not merely the detected or declared charset. Missing content
gives an allocated empty string and "us-ascii"; empty content is decoded
using the normal charset selection. used_charset
is NULL on any error.
Transfer-decoded bytes are read once, honoring content decode-to-stream overrides. The complete buffered prefix is used for BOM detection, even when the source produces short reads. Newlines follow the default GMimeFormatOptions. BOMs and bare CRs are retained; no final newline is added. No flowed-text conversion or markup conversion is done.
I/O and conversion failures never return partial text. Embedded decoded NULs
report G_CONVERT_ERROR_EMBEDDED_NUL. Source-backed content must remain open
and unchanged; successful decoding rewinds its stream, while failures may
leave it advanced. Headers and content bytes remain unchanged.
Free both the returned text and used_charset
with g_free().
mime_part |
||
used_charset |
the charset actually used. |
[out][optional][nullable][transfer full] |
error |
return location for an error, or |
void g_mime_text_part_set_text (GMimeTextPart *mime_part,const char *text);
Sets the specified text as the content and updates the charset parameter on the Content-Type header.