I have a WAVE file with cue points. One of them has the label "Marker 01 abcäöüß". Yet when I call listCuePoints(), the corresponding label string is "Marker 01 abcä�ö�ü�ß�".
The reason for this is that the method WaveFile.readZSTR_ tries to convert the string byte by byte, which gives wrong results for multi-byte UTF-8 code points.
I found an easy fix. Given that this project is currently unmaintained, I'm not opening a PR. Instead, here's a small snippet of code that patches the bug at runtime:
const WaveFile = require('wavefile');
const { unpackString } = require('byte-data');
WaveFile.prototype.readZSTR_ = function patchedReadZSTR_(bytes, start = 0) {
let end = start;
while (end < bytes.length && bytes[end]) end++;
return unpackString(bytes, start, end);
}
I have a WAVE file with cue points. One of them has the label "Marker 01 abcäöüß". Yet when I call
listCuePoints()
, the corresponding label string is "Marker 01 abcä�ö�ü�ß�".The reason for this is that the method
WaveFile.readZSTR_
tries to convert the string byte by byte, which gives wrong results for multi-byte UTF-8 code points.I found an easy fix. Given that this project is currently unmaintained, I'm not opening a PR. Instead, here's a small snippet of code that patches the bug at runtime: