## GtkSourceEncoding GtkSourceEncoding — Character encoding |

## Functions

const GtkSourceEncoding * | gtk_source_encoding_get_utf8 ()
const GtkSourceEncoding * | gtk_source_encoding_get_current ()
const GtkSourceEncoding * | gtk_source_encoding_get_from_charset ()
gchar * | gtk_source_encoding_to_string ()
const gchar * | gtk_source_encoding_get_name ()
const gchar * | gtk_source_encoding_get_charset ()
GSList * | gtk_source_encoding_get_all ()
GSList * | gtk_source_encoding_get_default_candidates ()
GtkSourceEncoding * | gtk_source_encoding_copy ()
void | gtk_source_encoding_free ()

## Types and Values

| GtkSourceEncoding

## Object Hierarchy

        GBoxed
        ╰── GtkSourceEncoding

## Includes

    #include <gtksourceview/gtksource.h>

## Description

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

## Functions

### gtk_source_encoding_get_utf8 ()

    const GtkSourceEncoding *
    gtk_source_encoding_get_utf8 (void);

#### Returns

the UTF-8 encoding.

Since: 3.14

### gtk_source_encoding_get_current ()

    const GtkSourceEncoding *
    gtk_source_encoding_get_current (void);

Gets the GtkSourceEncoding for the current locale. See also `g_get_charset()`.

#### Returns

the current locale encoding.

Since: 3.14

### gtk_source_encoding_get_from_charset ()

    const GtkSourceEncoding *
    gtk_source_encoding_get_from_charset (const gchar *charset);

Gets a GtkSourceEncoding from a character set such as "UTF-8" or "ISO-8859-1".

#### Parameters

charset | a character set. |

#### Returns

the corresponding GtkSourceEncoding, or `NULL` if not found.

[nullable]

Since: 3.14

### gtk_source_encoding_to_string ()

    gchar *
    gtk_source_encoding_to_string (const GtkSourceEncoding *enc);

#### Parameters

enc | a GtkSourceEncoding. |

#### Returns

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

Since: 3.14

### gtk_source_encoding_get_name ()

    const gchar *
    gtk_source_encoding_get_name (const GtkSourceEncoding *enc);

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

#### Parameters

enc | a GtkSourceEncoding. |

#### Returns

the name of the GtkSourceEncoding.

Since: 3.14

### gtk_source_encoding_get_charset ()

    const gchar *
    gtk_source_encoding_get_charset (const GtkSourceEncoding *enc);

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

#### Parameters

enc | a GtkSourceEncoding. |

#### Returns

the character set of the GtkSourceEncoding.

Since: 3.14

### gtk_source_encoding_get_all ()

    GSList *
    gtk_source_encoding_get_all (void);

Gets all encodings.

#### Returns

a list of all GtkSourceEncoding's. Free with `g_slist_free()`.

[transfer container][element-type GtkSource.Encoding]

Since: 3.14

### gtk_source_encoding_get_default_candidates ()

    GSList *
    gtk_source_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. Free with `g_slist_free()`.

[transfer container][element-type GtkSource.Encoding]

Since: 3.18

### gtk_source_encoding_copy ()

    GtkSourceEncoding *
    gtk_source_encoding_copy (const GtkSourceEncoding *enc);

Used by language bindings.

#### Parameters

enc | a GtkSourceEncoding. |

#### Returns

a copy of `enc` .

Since: 3.14

### gtk_source_encoding_free ()

    void
    gtk_source_encoding_free (GtkSourceEncoding *enc);

Used by language bindings.

#### Parameters

enc | a GtkSourceEncoding. |

Since: 3.14

## Types and Values

### GtkSourceEncoding

    typedef struct _GtkSourceEncoding GtkSourceEncoding;

## See Also

GtkSourceFileSaver, GtkSourceFileLoader