microsoft / microsoft/pxt-microbit
Bugs in using escape characters
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
micro:bit-support: 21346
Describe the bug
In blocks entering within Serial Write Line, Serial Write String on in a general string assignment, entering a character escape sequence such as “\r” adds extra “\”
If the character required is \”, then two extra \ are added.

Entering a character escape sequence in Javascript gives an unrendered block sometimes.
A round trip from JS to blocks back to JS results in a null being added at the front i.e if the string is “\r” then the round trip results in “” + “\r”

Entering hex number as a character escape crashes program and all work is lost e.g. for control-Z “\0x1a”

There is a documented block https://makecode.microbit.org/reference/math/from-char-code to enter a character code that renders if you use eg let ctrlZ = String.fromCharCode(26) and switched to bklocks, but this doesn't appear in the Text Block menu. Can this be added?

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported cases in Serial Write Line, Serial Write String, general string assignments, and the JavaScript-to-blocks round trip. Check the existing math/from-char-code entry point and the Text Block menu. Done means escape sequences round-trip correctly, hexadecimal input does not crash or lose work, and the documented character-code block is available in the Text Block menu.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100