bjelorsiberg
New Member
In a web application with \[code\]<meta charset="utf-8">\[/code\] I get the ID3 tags of mp3 files like this:\[code\]var reader = new FileReader();reader.onload = function(onloadEvent) { var mp3Data = http://stackoverflow.com/questions/15859908/new jDataView(onloadEvent.result); if (mp3Data.getString(3, mp3Data.byteLength - 128) =='TAG') { doSomethingWithMetadata({ name: mp3Data.getString(30, mp3Data.tell()), artist: mp3Data.getString(30, mp3Data.tell()), album: mp3Data.getString(30, mp3Data.tell()), year: mp3Data.getString(4, mp3Data.tell()) }); }}reader.readAsArrayBuffer(file);\[/code\]Special characters show correctly when I do this. I later moved the tag processing to a webworker:\[code\]var reader = new FileReaderSync();var mp3Data = http://stackoverflow.com/questions/15859908/new jDataView(reader.readAsArrayBuffer(file));if (mp3Data.getString(3, mp3Data.byteLength - 128) =='TAG') { postMessage({ name: mp3Data.getString(30, mp3Data.tell()), artist: mp3Data.getString(30, mp3Data.tell()), album: mp3Data.getString(30, mp3Data.tell()), year: mp3Data.getString(4, mp3Data.tell()) });}\[/code\]The names and artists of songs with special characters are now interpreted as ?????. Is it reasonable to assume this is happens because the web worker doesn't decode with UTF?If yes, can I make the web worker use UTF or pass the binary back to the main web page and then decode it?