[gimp/gimp-2-10] plug-ins: in metadata editor and viewer only convert values to UTF-8 if they are not.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] plug-ins: in metadata editor and viewer only convert values to UTF-8 if they are not.
- Date: Fri, 20 Nov 2020 02:51:21 +0000 (UTC)
commit baa063e6874c1f92f579eff8081fd839bd2478c5
Author: Jacob Boerema <jgboerema gmail com>
Date: Thu Nov 19 17:33:41 2020 -0500
plug-ins: in metadata editor and viewer only convert values to UTF-8 if they are not.
Certain metadata is already UTF-8. Converting them from locale
to UTF-8 again leads to incorrectly shown strings.
(cherry picked from commit 3128047a0b09c6d2d54dcd8a349676045fde40ab)
plug-ins/metadata/metadata-editor.c | 10 +++++++++-
plug-ins/metadata/metadata-viewer.c | 9 ++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/metadata/metadata-editor.c b/plug-ins/metadata/metadata-editor.c
index 146e9a5504..43e9e36ed9 100644
--- a/plug-ins/metadata/metadata-editor.c
+++ b/plug-ins/metadata/metadata-editor.c
@@ -653,7 +653,15 @@ clean_xmp_string (const gchar *value)
}
}
- value_utf8 = g_locale_to_utf8 (value_clean, -1, NULL, NULL, NULL);
+ if (! g_utf8_validate (value_clean, -1, NULL))
+ {
+ value_utf8 = g_locale_to_utf8 (value_clean, -1, NULL, NULL, NULL);
+ }
+ else
+ {
+ value_utf8 = g_strdup (value_clean);
+ }
+
g_free (value_clean);
return value_utf8;
diff --git a/plug-ins/metadata/metadata-viewer.c b/plug-ins/metadata/metadata-viewer.c
index 41e4be909a..b70182f21c 100644
--- a/plug-ins/metadata/metadata-viewer.c
+++ b/plug-ins/metadata/metadata-viewer.c
@@ -415,7 +415,14 @@ metadata_dialog_format_tag_value (GExiv2Metadata *metadata,
gchar *value_utf8;
value = gexiv2_metadata_get_tag_interpreted_string (metadata, tag);
- value_utf8 = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
+ if (! g_utf8_validate (value, -1, NULL))
+ {
+ value_utf8 = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
+ }
+ else
+ {
+ value_utf8 = g_strdup (value);
+ }
g_free (value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]