diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libtracker-extract/tracker-guarantee.c | 22 | ||||
-rw-r--r-- | src/libtracker-extract/tracker-guarantee.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/libtracker-extract/tracker-guarantee.c b/src/libtracker-extract/tracker-guarantee.c index 9b8460a08..5c595c9ad 100644 --- a/src/libtracker-extract/tracker-guarantee.c +++ b/src/libtracker-extract/tracker-guarantee.c @@ -348,3 +348,25 @@ tracker_guarantee_resource_date_from_file_mtime (TrackerResource *resource, return success; } + +gboolean +tracker_guarantee_resource_utf8_string (TrackerResource *resource, + const gchar *key, + const gchar *value) +{ + const gchar *end; + gchar *str; + + if (!g_utf8_validate (value, -1, &end)) { + if (end == value) + return FALSE; + + str = g_strndup (value, end - value); + tracker_resource_set_string (resource, key, str); + g_free (str); + } else { + tracker_resource_set_string (resource, key, value); + } + + return TRUE; +} diff --git a/src/libtracker-extract/tracker-guarantee.h b/src/libtracker-extract/tracker-guarantee.h index 9b58a634a..cdb28c24a 100644 --- a/src/libtracker-extract/tracker-guarantee.h +++ b/src/libtracker-extract/tracker-guarantee.h @@ -49,6 +49,9 @@ gboolean tracker_guarantee_resource_date_from_file_mtime (TrackerResource *reso const gchar *key, const gchar *current_value, const gchar *uri); +gboolean tracker_guarantee_resource_utf8_string (TrackerResource *resource, + const gchar *key, + const gchar *value); G_END_DECLS |