Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode text is not read correctly #13

Closed
DanielSWolf opened this issue Apr 6, 2019 · 1 comment
Closed

Unicode text is not read correctly #13

DanielSWolf opened this issue Apr 6, 2019 · 1 comment

Comments

@DanielSWolf
Copy link

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);
}
@rochars
Copy link
Owner

rochars commented Jul 25, 2019

This is issue is fixed in version 8.4.5.

Thanks!

@rochars rochars closed this as completed Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants