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

Invalid Continuation Byte #3

Closed
miclol opened this issue Aug 20, 2021 · 1 comment
Closed

Invalid Continuation Byte #3

miclol opened this issue Aug 20, 2021 · 1 comment

Comments

@miclol
Copy link

miclol commented Aug 20, 2021

When I try to read this nbs file: Can't read this.zip (which has been zipped because I can't drag the file onto here directly) it says:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 13: invalid continuation byte

@Bentroen
Copy link
Member

Bentroen commented Aug 21, 2021

Hi! There's currently an issue with the way Note Block Studio encodes strings. Although characters to be written are encoded as UTF-16, NBS only writes the rightmost byte to the file. However, when reading it back into a character, it uses the system's encoding - ANSI, since it runs on Windows -, which, in spite of producing an incorrect character, doesn't result in an error when opening the song, since ANSI has a codepoint for every possible byte.

In this particular case, the MIDI you created the song from seems to contain Japanese characters. Since an encoding is not being specified in pynbs, it's being assumed as UTF-8. Due to the buggy value written to the file, some bytes may actually turn out to be invalid UTF-8, resulting in the error. The best we can do here is to read the string using the ANSI codec to mimic the behavior of NBS, which will still result in incorrect characters, but at least won't cause an error. Eventually, NBS must be patched to handle special characters a bit better than simply truncating the bytes.

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