Handling ID3 tags with non-latin1 encoding
[email protected] (Stefan Huelswitt) Mon, 5 Jun 2006 09:06:00 +0000 (UTC)
| Newsgroups | gmane.comp.audio.mad.devel |
|---|---|
| Organization | Home, sweet home |
| Message-ID | <[email protected]> |
Hi,
I have a question regarding handling of ID3 tags which are
non-latin1 encoded e.g. iso-8859-5.
I think I can get ucs4 strings from libid3tag and convert them
with iconv to whatever codeset originaly was used.
How can I get information about the original codeset?
Is there another designated way to handle these cases?
My current code to get a string for an ID3 tag is (FYI: it's
VDR-MP3 player plugin):
void cScanID3::ParseStr(const struct id3_tag *tag, const char *id, char * &data)
{
const struct id3_frame *frame=id3_tag_findframe(tag,id,0);
if(!frame) return;
free(data); data=0;
const union id3_field *field=&frame->fields[1];
if(id3_field_getnstrings(field)>0) {
const id3_ucs4_t *ucs4=id3_field_getstrings(field,0);
if(!ucs4) return;
if(!strcmp(id,ID3_FRAME_GENRE)) ucs4=id3_genre_name(ucs4);
id3_latin1_t *latin1=id3_ucs4_latin1duplicate(ucs4);
if(!latin1) return;
data=strdup((char *)latin1);
free(latin1);
}
}
Obviously the code yields bad results, if the string wasn't in
latin1 originaly.
TIA.
Regards.
--
Stefan Huelswitt
[email protected] | http://www.muempf.de/