Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set encoding to
cp1252
for read/written strings
Prevents `UnicodeDecodeError: invalid continuation byte` when decoding non-ASCII characters, due to a bug in Note Block Studio where only the first byte of the character's UTF-16 codepoint is written to the file, resulting in an invalid UTF-8 codepoint. This will be patched in a future version of the NBS format (see OpenNBS/OpenNoteBlockStudio#307). `cp1252` was chosen to closely match the current (unintended) interpretation of those characters by Note Block Studio, given the fact that it has always been a Windows-only application. Also, unlike ISO-8859-1/Latin-1, all characters in the `0x8A-0xFF` range are printable characters (whereas `0x80-0x9F` are control characters in Latin-1). By no means this is an ideal solution -- it's nothing short of a workaround to prevent that exception, until the issue is properly fixed in Note Block Studio. As the information in those characters is already lost the moment they are saved to the file, it's preferable to have the read process yield "garbage" characters than incur in an exception. Fixes #3
- Loading branch information