GtefEncoding: Gtef 2 Reference Manual

## GtefEncoding GtefEncoding — Character encoding |

## Functions

GtefEncoding * | gtef_encoding_new ()
GtefEncoding * | gtef_encoding_new_utf8 ()
GtefEncoding * | gtef_encoding_new_from_locale ()
GtefEncoding * | gtef_encoding_copy ()
void | gtef_encoding_free ()
const gchar * | gtef_encoding_get_charset ()
const gchar * | gtef_encoding_get_name ()
gchar * | gtef_encoding_to_string ()
gboolean | gtef_encoding_is_utf8 ()
gboolean | gtef_encoding_equals ()
GSList * | gtef_encoding_get_all ()
GSList * | gtef_encoding_get_default_candidates ()

## Types and Values

| GtefEncoding

## Object Hierarchy

        GBoxed
        ╰── GtefEncoding

## Includes

    #include <gtef/gtef.h>

## Description

The GtefEncoding boxed type represents a character encoding. It is used for example by GtefFile. Note that the text in GTK+ widgets is always encoded in UTF-8.

GtefEncoding is a fork of GtkSourceEncoding with a different API to accommodate the new GtefFileLoader implementation.

## Functions

### gtef_encoding_new ()

    GtefEncoding *
    gtef_encoding_new (const gchar *charset);

Creates a new GtefEncoding from a character set such as "UTF-8" or "ISO-8859-1".

#### Parameters

charset | a character set. |

#### Returns

the new GtefEncoding. Free with `gtef_encoding_free()`.

Since: 2.0

### gtef_encoding_new_utf8 ()

    GtefEncoding *
    gtef_encoding_new_utf8 (void);

Creates a new GtefEncoding with the "UTF-8" character set.

#### Returns

the new GtefEncoding. Free with `gtef_encoding_free()`.

Since: 2.0

### gtef_encoding_new_from_locale ()

    GtefEncoding *
    gtef_encoding_new_from_locale (void);

Creates a new GtefEncoding from the current locale, as returned by `g_get_charset()`.

#### Returns

the new GtefEncoding. Free with `gtef_encoding_free()`.

Since: 2.0

### gtef_encoding_copy ()

    GtefEncoding *
    gtef_encoding_copy (const GtefEncoding *enc);

#### Parameters

enc | a GtefEncoding. |

#### Returns

a copy of `enc` .

[transfer full]

Since: 2.0

### gtef_encoding_free ()

    void
    gtef_encoding_free (GtefEncoding *enc);

#### Parameters

enc | a GtefEncoding, or `NULL`. | [nullable]

Since: 2.0

### gtef_encoding_get_charset ()

    const gchar *
    gtef_encoding_get_charset (const GtefEncoding *enc);

Gets the character set of the GtefEncoding, such as "UTF-8" or "ISO-8859-1".

#### Parameters

enc | a GtefEncoding. |

#### Returns

the character set of the GtefEncoding.

Since: 2.0

### gtef_encoding_get_name ()

    const gchar *
    gtef_encoding_get_name (const GtefEncoding *enc);

Gets the name of the GtefEncoding such as "Unicode" or "Western".

#### Parameters

enc | a GtefEncoding. |

#### Returns

the name of the GtefEncoding.

Since: 2.0

### gtef_encoding_to_string ()

    gchar *
    gtef_encoding_to_string (const GtefEncoding *enc);

Returns the encoding name with the charset in parenthesis, for example "Unicode (UTF-8)". If the name is unknown, just the charset is returned.

#### Parameters

enc | a GtefEncoding. |

#### Returns

a string representation. Free with `g_free()` when no longer needed.

Since: 2.0

### gtef_encoding_is_utf8 ()

    gboolean
    gtef_encoding_is_utf8 (const GtefEncoding *enc);

#### Parameters

enc | a GtefEncoding. |

#### Returns

whether `enc` is a UTF-8 encoding.

Since: 2.0

### gtef_encoding_equals ()

    gboolean
    gtef_encoding_equals (const GtefEncoding *enc1,
                          const GtefEncoding *enc2);

#### Parameters

enc1 | a GtefEncoding, or `NULL`. | [nullable]
enc2 | a GtefEncoding, or `NULL`. | [nullable]

#### Returns

whether `enc1` and `enc2` are equals.

Since: 2.0

### gtef_encoding_get_all ()

    GSList *
    gtef_encoding_get_all (void);

Gets a list of all encodings known by GtefEncoding.

#### Returns

a list of GtefEncoding's.

[transfer full][element-type GtefEncoding]

Since: 2.0

### gtef_encoding_get_default_candidates ()

    GSList *
    gtef_encoding_get_default_candidates (void);

Gets the list of default candidate encodings to try when loading a file. See `gtk_source_file_loader_set_candidate_encodings()`.

This function returns a different list depending on the current locale (i.e. language, country and default encoding). The UTF-8 encoding and the current locale encoding are guaranteed to be present in the returned list.

#### Returns

the list of default candidate encodings.

[transfer full][element-type GtefEncoding]

Since: 2.0

## Types and Values

### GtefEncoding

    typedef struct _GtefEncoding GtefEncoding;

## See Also

GtefFileSaver, GtefFileLoader