| Top |
| void | g_mime_charset_map_init () |
| void | g_mime_charset_map_shutdown () |
| const char * | g_mime_locale_charset () |
| const char * | g_mime_locale_language () |
| const char * | g_mime_charset_language () |
| const char * | g_mime_charset_canon_name () |
| const char * | g_mime_charset_iconv_name () |
| const char * | g_mime_charset_name () |
| const char * | g_mime_charset_locale_name () |
| const char * | g_mime_charset_iso_to_windows () |
| gboolean | g_mime_charset_try_get_bom_encoding () |
| gboolean | g_mime_charset_try_get_bom_encoding_from_stream () |
| void | g_mime_charset_init () |
| void | g_mime_charset_step () |
| const char * | g_mime_charset_best_name () |
| const char * | g_mime_charset_best () |
| gboolean | g_mime_charset_can_encode () |
void
g_mime_charset_map_init (void);
Initializes character set maps.
Note: g_mime_init() calls this routine for you.
void
g_mime_charset_map_shutdown (void);
Frees internal lookup tables created in g_mime_charset_map_init().
const char *
g_mime_locale_charset (void);
Gets the user's locale charset (or iso-8859-1 by default).
const char *
g_mime_locale_language (void);
Gets the user's locale language code (or NULL by default).
const char *
g_mime_charset_language (const char *charset);
Attempts to find a specific language code that is specific to
charset
. Currently only handles CJK and Russian/Ukranian
charset->lang mapping. Everything else will return NULL.
const char *
g_mime_charset_canon_name (const char *charset);
Attempts to find a canonical charset name for charset
.
Note: Will normally return the same value as
g_mime_charset_iconv_name() unless the system iconv does not use
the canonical ISO charset names (such as using ISO8859-1 rather
than the canonical form ISO-8859-1).
const char *
g_mime_charset_iconv_name (const char *charset);
Attempts to find an iconv-friendly charset name for charset
.
ISO numbers outside the unsigned-int range are left unnormalized.
const char *
g_mime_charset_name (const char *charset);
g_mime_charset_name is deprecated and should not be used in newly-written code.
Attempts to find an iconv-friendly charset name for charset
.
Note: This function is deprecated. Use g_mime_charset_iconv_name()
instead.
const char *
g_mime_charset_locale_name (void);
g_mime_charset_locale_name is deprecated and should not be used in newly-written code.
Gets the user's locale charset (or iso-8859-1 by default).
Note: This function is deprecated. Use g_mime_locale_charset()
instead.
const char *
g_mime_charset_iso_to_windows (const char *isocharset);
Maps the ISO-8859-# charset to the equivalent Windows-CP125# charset.
gboolean g_mime_charset_try_get_bom_encoding (const guint8 *buffer,gsize length,const char **charset);
Detects an initial UTF-16LE, UTF-16BE, or UTF-8 byte-order mark, returning
"utf-16le", "utf-16be", or "utf-8", respectively. At most three bytes are
inspected; incomplete marks do not match. buffer
may be NULL only when
length
is zero.
This follows MimeKit's BOM policy, not general Unicode encoding detection: UTF-32 is not detected, and its FF FE prefix matches UTF-16LE. No bytes are removed or decoded, and a detected mark remains part of the content.
buffer |
bytes to inspect. |
[array length=length][element-type guint8][nullable] |
length |
the number of available bytes |
|
charset |
a static charset name, or |
[out][nullable][transfer none] |
gboolean g_mime_charset_try_get_bom_encoding_from_stream (GMimeStream *stream,const char **charset,GError **error);
Reads up to three bytes at the stream's current position and applies
g_mime_charset_try_get_bom_encoding(). Exactly one read is attempted,
including on streams that return short reads. The stream is not rewound,
sought, or closed, and the inspected bytes remain consumed on either a
match or a nonmatch. A zero-byte read returns FALSE without an error.
A read failure returns FALSE with GMIME_ERROR using the stream's errno,
or GMIME_ERROR_GENERAL if the stream did not set errno. No charset is
returned on failure.
stream |
||
charset |
a static charset name, or |
[out][nullable][transfer none] |
error |
return location for an error, or |
void
g_mime_charset_init (GMimeCharset *charset);
Initializes a charset mask structure.
void g_mime_charset_step (GMimeCharset *charset,const char *inbuf,size_t inlen);
Steps through the input buffer 1 unicode character (glyph) at a
time (ie, not necessarily 1 byte at a time). Bitwise 'and' our
charset->mask
with the mask for each glyph. This has the effect of
limiting what charsets our charset->mask
can match.
const char *
g_mime_charset_best_name (GMimeCharset *charset);
Gets the best charset name based on the charset mask charset
.
the charset name that best represents the charset
mask charset
or NULL for us-ascii.
[nullable]
const char * g_mime_charset_best (const char *inbuf,size_t inlen);
Computes the best charset to use to encode this text buffer.
gboolean g_mime_charset_can_encode (GMimeCharset *mask,const char *charset,const char *text,size_t len);
Check to see if the UTF-8 text
will fit safely within charset
.
struct GMimeCharset {
unsigned int mask;
unsigned int level;
};
State used by g_mime_charset_best() and g_mime_charset_best_name().