camel-utf8: Camel Reference Manual

## camel-utf8 camel-utf8 |

## Functions

void | camel_utf8_putc ()
guint32 | camel_utf8_getc ()
guint32 | camel_utf8_getc_limit ()
void | g_string_append_u ()
gchar * | camel_utf7_utf8 ()
gchar * | camel_utf8_utf7 ()
gchar * | camel_utf8_ucs2 ()
gchar * | camel_ucs2_utf8 ()
gchar * | camel_utf8_make_valid ()

## Description

## Functions

### camel_utf8_putc ()

    void
    camel_utf8_putc (guchar **ptr,
                     guint32 c);

Output a 32 bit unicode character as utf8 octets. At most 4 octets will be written to `ptr` . `ptr` will be advanced to the next character position.

### camel_utf8_getc ()

    guint32
    camel_utf8_getc (const guchar **ptr);

Get a Unicode character from a utf8 stream. `ptr` will be advanced to the next character position. Invalid utf8 characters will be silently skipped. `ptr` should point to a NUL terminated array.

#### Returns

The next Unicode character. `ptr` will be advanced to the next character always.

### camel_utf8_getc_limit ()

    guint32
    camel_utf8_getc_limit (const guchar **ptr,
                           const guchar *end);

Get the next utf8 gchar at `ptr` , and return it, advancing `ptr` to the next character. If `end` is reached before a full utf8 character can be read, then the invalid Unicode gchar 0xffff is returned as a sentinel (Unicode 3.1, section 2.7), and `ptr` is not advanced.

#### Parameters

end | must not be NULL. |

#### Returns

The next utf8 char, or 0xffff.

### g_string_append_u ()

    void
    g_string_append_u (GString *out,
                       guint32 c);

### camel_utf7_utf8 ()

    gchar *
    camel_utf7_utf8 (const gchar *ptr);

Convert a modified utf7 string to utf8. If the utf7 string contains 8 bit characters, they are treated as iso-8859-1.

The IMAP rules [rfc2060] are used in the utf7 encoding.

#### Returns

The converted string.

### camel_utf8_utf7 ()

    gchar *
    camel_utf8_utf7 (const gchar *ptr);

Convert a utf8 string to a modified utf7 format.

The IMAP rules [rfc2060] are used in the utf7 encoding.

### camel_utf8_ucs2 ()

    gchar *
    camel_utf8_ucs2 (const gchar *ptr);

Convert a utf8 string into a ucs2 one. The ucs string will be in network byte order, and terminated with a 16 bit NULL.

### camel_ucs2_utf8 ()

    gchar *
    camel_ucs2_utf8 (const gchar *ptr);

Convert a ucs2 string into a utf8 one. The ucs2 string is treated as network byte ordered, and terminated with a 16 bit NUL.

### camel_utf8_make_valid ()

    gchar *
    camel_utf8_make_valid (const gchar *text);

Ensures the returned text will be valid UTF-8 string, with incorrect letters changed to question marks. Returned pointer should be freed with g_free.

Since: 2.26

## Types and Values