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.
This commit is contained in:
Tim-Philipp Müller 2007-04-12 16:36:36 +00:00
parent 807258cc03
commit 83ab98b0fc
2 changed files with 31 additions and 23 deletions

View file

@ -1,3 +1,9 @@
2007-04-12 Tim-Philipp Müller <tim at centricular dot net>
* 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 <wim@fluendo.com>
* gst/videorate/gstvideorate.c: (gst_video_rate_setcaps),

View file

@ -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) {
while (env_vars && *env_vars != NULL) {
const gchar *env = NULL;
/* 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_strfreev (csets);
}
++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);
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_strfreev (csets);
}
/* 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;