Add unicode_fixup_mfi() to check & reencode UTF-8 fields in struct media_file_info

This commit is contained in:
Julien BLACHE 2010-06-21 17:50:09 +02:00
parent da0c10a392
commit 35d6ac4cfa
2 changed files with 37 additions and 0 deletions

View File

@ -351,6 +351,40 @@ free_mfi(struct media_file_info *mfi, int content_only)
free(mfi); free(mfi);
} }
void
unicode_fixup_mfi(struct media_file_info *mfi)
{
char *ret;
char **field;
int i;
for (i = 0; i < (sizeof(mfi_cols_map) / sizeof(mfi_cols_map[0])); i++)
{
if (mfi_cols_map[i].type != DB_TYPE_STRING)
continue;
switch (mfi_cols_map[i].offset)
{
case mfi_offsetof(path):
case mfi_offsetof(fname):
case mfi_offsetof(codectype):
continue;
}
field = (char **) ((char *)mfi + mfi_cols_map[i].offset);
if (!*field)
continue;
ret = unicode_fixup_string(*field);
if (ret != *field)
{
free(*field);
*field = ret;
}
}
}
void void
free_pli(struct playlist_info *pli, int content_only) free_pli(struct playlist_info *pli, int content_only)
{ {

View File

@ -268,6 +268,9 @@ free_pi(struct pairing_info *pi, int content_only);
void void
free_mfi(struct media_file_info *mfi, int content_only); free_mfi(struct media_file_info *mfi, int content_only);
void
unicode_fixup_mfi(struct media_file_info *mfi);
void void
free_pli(struct playlist_info *pli, int content_only); free_pli(struct playlist_info *pli, int content_only);