Microsoft MakeCode

New Line Delimiter

I am wondering how I enter the New Line delimiter from the keyboard on my MacBook Pro (late 2013) under MacOS 10.15.3. I am using

serial.onDataReceived(serial.delimiters(Delimiters.NewLine), function () {

})

on a USB-connected micro:bit to receive keyboard input from my computer. I have been successful using all of the available delimiters e.g. Colon, Comma, Dollar, Fullstop and Hash, except for NewLine. I have tried a variety of keystrokes and unicodes, including U+2424 which prints in the Terminal, using the Zsh Screen command, as NL. I can use console.log("\n") function to output New Line; but I have not been successful using the OnDataReceived function to recognize the New Line delimiter as input. Any thoughts?

It’s probably ASCII 13 aka “\r”. But I have not tried it.

Many thanks @mmoskal Your suggestion motivated me to go back and try a variety of New Line Unicodes. It appears that, for MacOS, the New Line delimiter is ASCII 10 or U+000A which, as far as I know, can only be entered, on my MacBook Pro, as Unicode Hex input 000A.

Yes! I generated a “text from char code” with a value of 10 and printed that.

so, on-screen of MakeCode-Blocks you see serial write string(text from char code(10)) and it does print a new line on the terminal screen

thanks! Appreciate it!

0x0A is Line Feed, rather than 0x0D which is Carriage return.
Its common to have LF/CR as a pair, but Unix type systems tend to strip one of them - IIRC the CR is stripped usually.
Dave