I wrote this function (in Objective-C) to update the contents of a tag for writing out later. Am I on the right track? Do I need to update both the UTF8 and the latin strings?
bool libid3tag_SetString (struct id3_tag const *tag, char const *id, NSString *newStr) { bool retVal = NO; struct id3_frame const *frame; id3_latin1_t *latin1; id3_utf8_t *utf8;
/* text information */
union id3_field const *field; unsigned int nstrings, j; extern id3_ucs4_t *id3_utf8_deserialize(id3_byte_t const **ptr, id3_length_t length);
if ((frame = id3_tag_findframe(tag, id, 0)) == nil) return NO;
field = &frame->fields[1]; nstrings = id3_field_getnstrings(field);
for (j = 0; j < nstrings; ++j) { id3_byte_t *ptr; id3_ucs4_t *ucs4;
switch (field->type) { case ID3_FIELD_TYPE_STRINGLIST: ptr = [ newStr UTF8String ]; ucs4 = id3_utf8_deserialize (&ptr, [ newStr length ]);
id3_field_setstrings (field, 1, &ucs4); free (ucs4); break;
case ID3_FIELD_TYPE_LATIN1LIST: ptr = [ newStr cString ]; ucs4 = id3_latin1_deserialize (&ptr, [ newStr length ]);
id3_field_setstrings (field, 1, &ucs4); free (ucs4); break; } } return YES; }