GflsEncodingConversion

GflsEncodingConversion — High-level character encoding conversion

Functions

Includes

#include <gfls/gfls.h>

Description

High-level character encoding conversion functions.

If you need more flexibility, there are lower-level utilities:

Functions

gfls_encoding_convert ()

GflsValidatedString *
gfls_encoding_convert (GBytes *input_bytes,
                       const GflsEncoding *from_encoding,
                       const GflsEncoding *to_encoding,
                       gboolean allow_invalid_bytes,
                       gboolean *lossy_conversion,
                       GError **error);

High-level function to convert a single GBytes.

[skip]

Parameters

input_bytes

the input GBytes.

 

from_encoding

source encoding.

 

to_encoding

destination encoding.

 

allow_invalid_bytes

whether to allow invalid bytes during the conversion.

 

lossy_conversion

whether GFLS_ICONV_RESULT_LOSSY_CONVERSION was encountered.

[out][optional]

error

location to a GError, or NULL to ignore errors.

 

Returns

the GflsValidatedString, or NULL on error.

[transfer full][nullable]

Since: 0.5


gfls_encoding_try_convert ()

gboolean
gfls_encoding_try_convert (GBytes *input_bytes,
                           const gchar *to_codeset,
                           const gchar *from_codeset);

Tries a conversion on input_bytes , discarding the output.

from_codeset and to_codeset must be compatible with iconv, see gfls_iconv_open().

If input_bytes ends with an incomplete multi-byte character, that part is ignored. So input_bytes can be for example the first chunk of a file when loading it.

Parameters

input_bytes

a GBytes.

 

to_codeset

destination codeset.

 

from_codeset

source codeset.

 

Returns

TRUE if and only if input_bytes can be converted without errors, without invalid characters and without fallback characters.

Since: 0.4