microbit-foundation / microbit-fs

A TypeScript library to manipulate the micro:bit MicroPython filesystem.
https://microbit-foundation.github.io/microbit-fs/
MIT License
12 stars 1 forks source link

Support unicode characters longer than a byte #1

Closed microbit-carlos closed 5 years ago

microbit-carlos commented 5 years ago

This bug has been "ported" from the PythonEditor: https://github.com/bbcmicrobit/PythonEditor/issues/60

At the moment the String.charCodeAt() method is used to get the user script character codes, and it's return value is stored in a Uint8Array. If the value returned is larger than a byte, as it would happen with some UTF-8 characters, then some of that information is lost and the wrong character is encoded into the hex file.

The code is in the src/common.ts file: https://github.com/microbit-foundation/js-microbit-micropython-fs/blob/ee7081de3b29faf91407eb3535bf0b8cc29fb334/src/common.ts#L7-L18

https://github.com/microbit-foundation/js-microbit-micropython-fs/blob/ee7081de3b29faf91407eb3535bf0b8cc29fb334/src/common.ts#L22-L31

microbit-carlos commented 5 years ago

Fixed in #5 #6, thanks Ross!