tag: id3v2: If strings in text fields are marked ISO8859-1, but contain valid UTF-8 already, then han...

Original commit message from CVS:
* gst-libs/gst/tag/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)
This commit is contained in:
Jan Schmidt 2006-08-22 13:53:34 +00:00 committed by Tim-Philipp Müller
parent 075ceac5e7
commit 8bdde43777

View file

@ -273,12 +273,12 @@ parse_text_identification_frame (ID3TagsWorking * work)
work->parse_size - 1, &fields); work->parse_size - 1, &fields);
if (fields) { if (fields) {
if (fields->len > 0) { if (fields->len > 0) {
GST_LOG ("Read %d fields from Text ID frame of size %d. First is '%s'", GST_LOG ("Read %d fields from Text ID frame of size %d with encoding %d"
fields->len, work->parse_size - 1, ". First is '%s'", fields->len, work->parse_size - 1, encoding,
g_array_index (fields, gchar *, 0)); g_array_index (fields, gchar *, 0));
} else { } else {
GST_LOG ("Read %d fields from Text ID frame of size %d", fields->len, GST_LOG ("Read 0 fields from Text ID frame of size %d with encoding %d",
work->parse_size - 1); work->parse_size - 1, encoding);
} }
} }
@ -911,8 +911,11 @@ parse_insert_string_field (guint8 encoding, gchar * data, gint data_size,
break; break;
case ID3V2_ENCODING_ISO8859: case ID3V2_ENCODING_ISO8859:
field = g_convert (data, data_size, "UTF-8", "ISO-8859-1", if (g_utf8_validate (data, data_size, NULL))
NULL, NULL, NULL); field = g_strndup (data, data_size);
else
field = g_convert (data, data_size, "UTF-8", "ISO-8859-1",
NULL, NULL, NULL);
break; break;
default: default:
field = g_strndup (data, data_size); field = g_strndup (data, data_size);