| Top |
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.
TRUE if and only if input_bytes
can be converted without errors,
without invalid characters and without fallback characters.
Since: 0.4
gboolean gfls_encoding_convert (GBytes *input_bytes,const gchar *to_codeset,const gchar *from_codeset,gboolean allow_invalid_characters,GBytes **output_bytes,GflsBytesRegion **output_bytes_valid_region,GError **error);
This function converts input_bytes
from a codeset to another.
from_codeset
and to_codeset
must be compatible with iconv, see
gfls_iconv_open().
Note that from_codeset
and to_codeset
can be equal. It is useful to
identify the valid characters from the invalid ones.
The output is the combination of output_bytes
and
output_bytes_valid_region
. Output bytes that are part of
output_bytes_valid_region
are the valid characters (successfully converted).
The other output bytes are invalid characters (copied as is from
input_bytes
).
If allow_invalid_characters
is FALSE:
As soon as an invalid character is encountered, FALSE is returned by this
function and output_bytes
and output_bytes_valid_region
will return
NULL.
Otherwise, if everything goes well, TRUE is returned alongside the
output_bytes
and output_bytes_valid_region
(the latter contains in this
case only one, valid sub-region).
input_bytes |
the input GBytes to convert. |
|
to_codeset |
destination codeset. |
|
from_codeset |
source codeset. |
|
allow_invalid_characters |
whether invalid characters are allowed. |
|
output_bytes |
the output GBytes. It must initially
point to a |
[out][transfer full] |
output_bytes_valid_region |
the output
GflsBytesRegion that represents the valid characters. It must initially
point to a |
[out][transfer full] |
error |
Since: 0.4