| Top |
| void | (*GflsEncodingConverterCallback) () |
| GflsEncodingConverter * | gfls_encoding_converter_new () |
| gboolean | gfls_encoding_converter_get_allow_invalid_bytes () |
| void | gfls_encoding_converter_set_allow_invalid_bytes () |
| void | gfls_encoding_converter_set_callback () |
| gboolean | gfls_encoding_converter_open () |
| gboolean | gfls_encoding_converter_feed () |
| gboolean | gfls_encoding_converter_finish_feeding () |
| gboolean | gfls_encoding_converter_get_lossy_conversion () |
A utility class to convert from one character encoding to another.
A GflsEncodingConverter object can be used only for one conversion. Call the functions in this order:
gfls_encoding_converter_new()
gfls_encoding_converter_set_allow_invalid_bytes()
gfls_encoding_converter_set_callback() to get the output.
gfls_encoding_converter_open()
gfls_encoding_converter_feed(), several times if streaming is desired.
gfls_encoding_converter_finish_feeding()
Finally gfls_encoding_converter_get_lossy_conversion() can be called to
know more about how the conversion was performed.
void (*GflsEncodingConverterCallback) (GBytes *bytes,gboolean is_valid,gpointer user_data);
This callback function is called when there is an output chunk from the GflsEncodingConverter.
bytes
is always nul-terminated, but this is not included in the GBytes
length.
If is_valid
is TRUE, the chunk has been successfully converted.
If is_valid
is FALSE, the bytes
is a copy of the input bytes for which the
conversion failed. Note especially that the bytes
have not been escaped; for
that, you can call a function like gfls_utils_bytes_to_hex_representation().
GflsEncodingConverter makes no attempts to coalesce contiguous chunks of the
same kind. In other words, this callback can be called many times in a row
with the same value for is_valid
.
You need to either use bytes
directly during the call of this callback, or
increase the reference count to store bytes
for later use. (When the call of
the callback finishes, GflsEncodingConverter decreases the reference count
of bytes
).
Since: 0.5
GflsEncodingConverter *
gfls_encoding_converter_new (void);
Since: 0.5
gboolean
gfls_encoding_converter_get_allow_invalid_bytes
(GflsEncodingConverter *converter);
Since: 0.5
void gfls_encoding_converter_set_allow_invalid_bytes (GflsEncodingConverter *converter,gboolean allow_invalid_bytes);
Sets whether to allow invalid bytes during the conversion.
Since: 0.5
void gfls_encoding_converter_set_callback (GflsEncodingConverter *converter,GflsEncodingConverterCallback callback,gpointer user_data);
Sets the GflsEncodingConverterCallback.
[skip]
converter |
||
callback |
function to call back to provide the output. |
|
user_data |
user data to pass to |
Since: 0.5
gboolean gfls_encoding_converter_open (GflsEncodingConverter *converter,const gchar *from_charset,const gchar *to_charset,GError **error);
Similar to gfls_iconv_open().
converter |
||
from_charset |
source charset. |
|
to_charset |
destination charset. |
|
error |
location to a GError, or |
Since: 0.5
gboolean gfls_encoding_converter_feed (GflsEncodingConverter *converter,const guint8 *data,gsize n_bytes,GError **error);
Feeds some input bytes to the converter
.
Can be called several times (useful for streaming scenarios).
The output is sent with the GflsEncodingConverterCallback.
converter |
||
data |
input bytes. |
|
n_bytes |
the number of input bytes. |
|
error |
location to a GError, or |
Since: 0.5
gboolean gfls_encoding_converter_finish_feeding (GflsEncodingConverter *converter,GError **error);
Finishes the input feeding.
Note that the GflsEncodingConverterCallback can be called by this function too.
Since: 0.5
gboolean
gfls_encoding_converter_get_lossy_conversion
(GflsEncodingConverter *converter);
Since: 0.5