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

Fix for instrument & preset name having garbage characters #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/binary_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ class BinaryReader
byteList[i] = data.getUint8(i);
}

String out = String.fromCharCodes(byteList);
// Find null terminator and trim the string until the first occurrence of it
int actualLength = byteList.indexOf(0);
if (actualLength == -1) {
// Take the whole string if not found
actualLength = length;
}

// remove null characters
out = String.fromCharCodes(out.codeUnits.where((code) => code != 0));
String out = String.fromCharCodes(byteList.getRange(0, actualLength));

return out;
}
Expand Down