Make g_utf8_make_valid optionally take a length

g_utf8_make_valid was turned into a public API this cycle. However
now that it is public we should make the API more generic, allowing
the caller to specify the length. This is especially useful if
the function is called with a string that has \0 in the middle
or for chunks of a strings that are not nul terminated.
This is also consistent with most of the other utf8 utils.

Callers inside glib are updated to the new signature.

https://bugzilla.gnome.org/show_bug.cgi?id=779456
This commit is contained in:
Paolo Borelli
2017-03-02 09:10:35 +01:00
committed by Ignacio Casal Quinteiro
parent 9aaf7588fc
commit f559bc01dc
5 changed files with 24 additions and 16 deletions

View File

@@ -885,7 +885,8 @@ gchar *g_utf8_collate_key_for_filename (const gchar *str,
gssize len) G_GNUC_MALLOC;
GLIB_AVAILABLE_IN_2_52
gchar *g_utf8_make_valid (const gchar *str);
gchar *g_utf8_make_valid (const gchar *str,
gssize len) G_GNUC_MALLOC;
G_END_DECLS