diff --git a/src/db.c b/src/db.c index efda780a..9f26fc78 100644 --- a/src/db.c +++ b/src/db.c @@ -351,6 +351,40 @@ free_mfi(struct media_file_info *mfi, int content_only) 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 free_pli(struct playlist_info *pli, int content_only) { diff --git a/src/db.h b/src/db.h index 119fec6a..5ab9fee5 100644 --- a/src/db.h +++ b/src/db.h @@ -268,6 +268,9 @@ free_pi(struct pairing_info *pi, int content_only); void free_mfi(struct media_file_info *mfi, int content_only); +void +unicode_fixup_mfi(struct media_file_info *mfi); + void free_pli(struct playlist_info *pli, int content_only);