From: Tim-Philipp Müller Date: Thu, 12 Apr 2007 16:36:36 +0000 (+0000) Subject: gst-libs/gst/tag/tags.c: Try encodings from all environment variables, not just those... X-Git-Tag: 1.19.3~511^2~11211 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83ab98b0fcf631f0f6e26ed2828ac4bda21d0197;p=platform%2Fupstream%2Fgstreamer.git gst-libs/gst/tag/tags.c: Try encodings from all environment variables, not just those in the first environment variab... Original commit message from CVS: * gst-libs/gst/tag/tags.c: (gst_tag_freeform_string_to_utf8): Try encodings from all environment variables, not just those in the first environment variable that is set. --- diff --git a/ChangeLog b/ChangeLog index 4aff7a4..5da8fa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-04-12 Tim-Philipp Müller + + * gst-libs/gst/tag/tags.c: (gst_tag_freeform_string_to_utf8): + Try encodings from all environment variables, not just those in the + first environment variable that is set. + 2007-04-12 Wim Taymans * gst/videorate/gstvideorate.c: (gst_video_rate_setcaps), diff --git a/gst-libs/gst/tag/tags.c b/gst-libs/gst/tag/tags.c index e1966cf..706ab96 100644 --- a/gst-libs/gst/tag/tags.c +++ b/gst-libs/gst/tag/tags.c @@ -246,7 +246,7 @@ gchar * gst_tag_freeform_string_to_utf8 (const gchar * data, gint size, const gchar ** env_vars) { - const gchar *env = NULL; + const gchar *cur_loc = NULL; gsize bytes_read; gchar *utf8 = NULL; @@ -260,33 +260,35 @@ gst_tag_freeform_string_to_utf8 (const gchar * data, gint size, if (g_utf8_validate (data, size, NULL)) return g_strndup (data, size); - while ((env == NULL || *env == '\0') && env_vars && *env_vars != NULL) { - env = g_getenv (*env_vars); - ++env_vars; - } - - /* Try charsets specified via the environment */ - if (env != NULL && *env != '\0') { - gchar **c, **csets; - - csets = g_strsplit (env, G_SEARCHPATH_SEPARATOR_S, -1); + while (env_vars && *env_vars != NULL) { + const gchar *env = NULL; - for (c = csets; c && *c; ++c) { - if ((utf8 = g_convert (data, size, "UTF-8", *c, &bytes_read, NULL, NULL))) { - if (bytes_read == size) { - g_strfreev (csets); - goto beach; + /* Try charsets specified via the environment */ + env = g_getenv (*env_vars); + if (env != NULL && *env != '\0') { + gchar **c, **csets; + + csets = g_strsplit (env, G_SEARCHPATH_SEPARATOR_S, -1); + + for (c = csets; c && *c; ++c) { + if ((utf8 = + g_convert (data, size, "UTF-8", *c, &bytes_read, NULL, NULL))) { + if (bytes_read == size) { + g_strfreev (csets); + goto beach; + } + g_free (utf8); + utf8 = NULL; } - g_free (utf8); - utf8 = NULL; } - } - g_strfreev (csets); + g_strfreev (csets); + } + ++env_vars; } /* Try current locale (if not UTF-8) */ - if (!g_get_charset (&env)) { + if (!g_get_charset (&cur_loc)) { if ((utf8 = g_locale_to_utf8 (data, size, &bytes_read, NULL, NULL))) { if (bytes_read == size) { goto beach;