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

Decoding UTF-16 Strings fails sometimes #4

Open
cameronleger opened this issue May 24, 2019 · 0 comments
Open

Decoding UTF-16 Strings fails sometimes #4

cameronleger opened this issue May 24, 2019 · 0 comments

Comments

@cameronleger
Copy link

I've found at least one recent Preset where the current method of reading a UTF-16 String in the PREPEND_LEN mode will fail. I have a fix and could PR, but I'm not sure I fully understand the situation so I'm starting with an issue.

In this case, the UTF-16 String will only decode in Big-Endian mode, and for some reason the default is Little-Endian. I don't know how the defaults or how Bitwig saves them are chosen.

My quick solution here is in read_str and to adjust the decoding portion to:

					str_bytes = self.read(str_len * (char_len))
					try:
						return str_bytes.decode(char_enc)
					except UnicodeDecodeError:
						return str_bytes.decode('utf-16-be')

It's not the best fail-safe, but in this case it's working for the existing and problem Presets.

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

1 participant