From 66bbbfb7692efd242fb5aa7c48daf98818e56d84 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 22 Aug 2006 13:53:34 +0000 Subject: [PATCH] gst/id3demux/id3v2frames.c: If strings in text fields are marked ISO8859-1, but contain valid UTF-8 already, then han... Original commit message from CVS: * gst/id3demux/id3v2frames.c: (parse_text_identification_frame), (parse_insert_string_field): If strings in text fields are marked ISO8859-1, but contain valid UTF-8 already, then handle them as UTF-8 and ignore the encoding. (#351794) --- ChangeLog | 8 ++++++++ gst/id3demux/id3v2frames.c | 15 +++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4fe1f7a8d..4b8cefa60b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-08-22 Jan Schmidt + + * gst/id3demux/id3v2frames.c: (parse_text_identification_frame), + (parse_insert_string_field): + If strings in text fields are marked ISO8859-1, but contain + valid UTF-8 already, then handle them as UTF-8 and ignore + the encoding. (#351794) + 2006-08-22 Tim-Philipp Müller * ext/flac/gstflacdec.c: (gst_flac_dec_scan_got_frame), diff --git a/gst/id3demux/id3v2frames.c b/gst/id3demux/id3v2frames.c index 4e98a5eb70..96fa88ec0d 100644 --- a/gst/id3demux/id3v2frames.c +++ b/gst/id3demux/id3v2frames.c @@ -273,12 +273,12 @@ parse_text_identification_frame (ID3TagsWorking * work) work->parse_size - 1, &fields); if (fields) { if (fields->len > 0) { - GST_LOG ("Read %d fields from Text ID frame of size %d. First is '%s'", - fields->len, work->parse_size - 1, + GST_LOG ("Read %d fields from Text ID frame of size %d with encoding %d" + ". First is '%s'", fields->len, work->parse_size - 1, encoding, g_array_index (fields, gchar *, 0)); } else { - GST_LOG ("Read %d fields from Text ID frame of size %d", fields->len, - work->parse_size - 1); + GST_LOG ("Read 0 fields from Text ID frame of size %d with encoding %d", + work->parse_size - 1, encoding); } } @@ -911,8 +911,11 @@ parse_insert_string_field (guint8 encoding, gchar * data, gint data_size, break; case ID3V2_ENCODING_ISO8859: - field = g_convert (data, data_size, "UTF-8", "ISO-8859-1", - NULL, NULL, NULL); + if (g_utf8_validate (data, data_size, NULL)) + field = g_strndup (data, data_size); + else + field = g_convert (data, data_size, "UTF-8", "ISO-8859-1", + NULL, NULL, NULL); break; default: field = g_strndup (data, data_size);