Geany dev
Enumerations | Functions
encodings.h File Reference

Encoding conversion and Byte Order Mark (BOM) handling. More...

Enumerations

enum  GeanyEncodingIndex
 List of known and supported encodings.
 

Functions

gchar * encodings_convert_to_utf8 (const gchar *buffer, gssize size, gchar **used_encoding)
 Tries to convert buffer into UTF-8 encoding and store the detected original encoding in used_encoding. More...
 
gchar * encodings_convert_to_utf8_from_charset (const gchar *buffer, gssize size, const gchar *charset, gboolean fast)
 Tries to convert buffer into UTF-8 encoding from the encoding specified with charset. More...
 
const gchar * encodings_get_charset_from_index (gint idx)
 Gets the character set name of the specified index e.g. More...
 

Detailed Description

Encoding conversion and Byte Order Mark (BOM) handling.

Function Documentation

◆ encodings_convert_to_utf8()

gchar * encodings_convert_to_utf8 ( const gchar *  buffer,
gssize  size,
gchar **  used_encoding 
)

Tries to convert buffer into UTF-8 encoding and store the detected original encoding in used_encoding.

Parameters
bufferthe input string to convert.
sizethe length of the string, or -1 if the string is nul-terminated.
used_encoding (out) return location of the detected encoding of the input string, or NULL.
Returns
If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise NULL.

◆ encodings_convert_to_utf8_from_charset()

gchar * encodings_convert_to_utf8_from_charset ( const gchar *  buffer,
gssize  size,
const gchar *  charset,
gboolean  fast 
)

Tries to convert buffer into UTF-8 encoding from the encoding specified with charset.

If fast is not set, additional checks to validate the converted string are performed.

Parameters
bufferThe input string to convert.
sizeThe length of the string, or -1 if the string is nul-terminated.
charsetThe charset to be used for conversion.
fastTRUE to only convert the input and skip extended checks on the converted string.
Returns
If the conversion was successful, a newly allocated nul-terminated string, which must be freed with g_free(). Otherwise NULL.

◆ encodings_get_charset_from_index()

const gchar * encodings_get_charset_from_index ( gint  idx)

Gets the character set name of the specified index e.g.

for use with document_set_encoding().

Parameters
idxGeanyEncodingIndex to retrieve the corresponding character set.
Returns
The charset according to idx, or NULL if the index is invalid.
Since
0.13