diff --git a/sound/CMakeLists.txt b/sound/CMakeLists.txt index ea19e15..d1f1d70 100644 --- a/sound/CMakeLists.txt +++ b/sound/CMakeLists.txt @@ -4,7 +4,7 @@ setup_lib(sound Sound) target_link_libraries( MDESound PRIVATE - MDECore + MDECore Mw ) pkg_config_add(MDESound vorbisfile) diff --git a/sound/id3.c b/sound/id3.c index 23046f7..56024c8 100644 --- a/sound/id3.c +++ b/sound/id3.c @@ -1,6 +1,8 @@ #include #include +#include + static unsigned int syncsafe(FILE* f) { unsigned char d[4]; unsigned int r = 0; @@ -98,25 +100,34 @@ char* MDEID3GetString(const char* path, const char* name) { s[sz - 1] = 0; if(d[0] == 1) { unsigned short bom = *(unsigned short*)&s[0]; + int incr = 0; - for(i = 1; i < sz - 1; i++) { + for(i = 1; i < (sz) / 2; i++) { if(bom == 0xfffe) { unsigned short n = 0; + char b[4]; + int l; n = n << 8; n = n | s[2 * i + 0]; n = n << 8; n = n | s[2 * i + 1]; - s[i - 1] = n & 0x7f; + l = MwUTF32ToUTF8(n, b); + memcpy(s + incr, b, l); + incr += l; } else if(bom == 0xfeff) { unsigned short n = 0; + char b[4]; + int l; n = n << 8; n = n | s[2 * i + 1]; n = n << 8; n = n | s[2 * i + 0]; - s[i - 1] = n & 0x7f; + l = MwUTF32ToUTF8(n, b); + memcpy(s + incr, b, l); + incr += l; } } - s[i - 1] = 0; + s[incr] = 0; } free(d);