Apart from \n what all escape characters does MIT app support?

\a, \b, \f, \n, \r, \t, \v, ', ", ? and \ are the commonly used escape characters. I do know \n is supported in a limited fashion. Can some one please update me of all the escape characters supported or escape characters that will be supported in the near future.
Also the follow up question is where in the code(GitHub) can I locate the code for supporting \n.


I do not think there is such code in GitHub, because naturally, TextView (i.e. Label) should support escape characters.

Perhaps inform on where and how and in what context you intend to use these characters. They only really have use in labels and textbox components, or in text strings (variables) but some have no or little effect.


I can only see effact for \n and \t and as Tim said

and \r have with no visible effact, maybe there is.

1 Like

At present, \n, \r, and \t are supported in the code generator (see Blockly.Yail.quotifyForREPL). However, depending on the context in App Inventor, some of those escapes are supported and some are not. Most design components understand \n (although sometimes the behavior differs slightly between the designer and app) but for \r and \t those are only available in the blocks editor. \r is mostly only useful for folks interacting with Windows systems where the line ending is \r\n (Android is Linux and iOS is Unix-y in nature, so both use \n for line endings). In general, we may want to support Unicode escape sequences with \u and then provide some of the others as syntactic sugar. Although outside of the work we are doing with IoT and microcontrollers I think they'll have somewhat limited applicability.


Sorry for the delay in getting back. Agree all we need are \n and \t. I am from the IBM punch card era and those days we needed \r and even to these days it exists but as part of \n.
\n = 0x0D+0A::Carriage Feed + Line Feed::\r + \n:: CR + LF. \n works fine. Coming to the \t we can see form the following example all it puts is a "Space = 0x20".

Here is the actual screen display

Evan thanks for sharing the source code. The comment says this:

  • Transform a string to the Kawa input representation of the string, for sending to
  • the REPL, by using backslash to escape quotes and backslashes. But do not escape a backslash
  • if it is part of \n. Then enclose the result in quotes.
  • TODO: Extend this to a complete transformation that deals with the full set of formatting
  • characters.
    Here they are not talking about \t just /n and it ties in with what I see in reality.
    Coming down to the code:

var sb = ;
var len = s.length;
var lastIndex = len - 1;
for (var i = 0; i < len; i++) {
c = s.charAt(i);
if (c == '\') {
// If this is \n, \t or \r don't slashify the backslash
// TODO(user): Make this cleaner and more general
if (!(i == lastIndex) && (s.charAt(i + 1) == 'n' || s.charAt(i + 1) == 't' || s.charAt(i + 1) == 'r')) {
sb.push(s.charAt(i + 1));
i = i + 1;
If i is not the last char in the line and the next char is n, t or r then save both of them.
In the case of \t it gets saved a single space = 0x20. Hence when I put a \t I get a single space. The modification to the code to make it all inclusive would be this. Please note I am dropping \r:
if (!(i == lastIndex)) {
if (s.charAt(i + 1) == 'n') {
sb.push(s.charAt(i + 1));
i = i + 1;
if (s.charAt(i + 1) == 't') {
sb.push(s.charAt(i + 1)); // Right now this is happening
sb.push(0x20(i + 2));
sb.push(0x20(i + 3));
sb.push(0x20(i + 4));
sb.push(0x20(i + 5)); // Adding 4 spaces
i = i + 5;
// len increases too. This modification will need more thought. For now it is the overall idea.
Back in the 80's UNIX introduced vi editor which introduced the concept of Tab space. By default it was set to 4 spaces and we could reset as :se ts=8 or :se ts=16 etc ...
My idea is try the above fix and see how it works and then give the user to set the tab space to what ever they want.
Please note I am absolutely new to JAVA/JS and GitHub. So mine is just an idea and I am sure might have syntax and logic bugs. Once I get some comments I can give it a try but will take some time to install all the needed things and familiarizing myself with their usage.

1 Like

I'll have to look at it further. But in the meantime, you can take a look at the code being sent to the companion by opening the browser's developer tools and looking at the (Scheme) code that is output there when you're connected to the companion app. That would give some insight as to whether we are inappropriately handling the \\ escapes.

Edit: Just as a follow up, it might also be that App Inventor is correctly passing through the tab character to Android, but that Android itself simply converts it into a space, similar to how strings of whitespace in HTML are all reduced to a single space character. Under these circumstances, we'd have to think very carefully about how we'd want to interpret a tab character in each component.


The string that get passed between the App Inventor and AI Companion app looks fine

This is the single line I am passing

The strange outcome I see on the Android phone (with 2 spaces) hints at an issue in the code you shared.
You will see a space in 2 spots where there was a \t and no space at 2 other \t locations. This random spaces speak of a much bigger bug.
Then to eliminate the Chrome I built an apk and installed it on my Android phone the output did not change. Same as before. So I would conclude the issue is local to the the MIT App inventor.
Evan your thoughts on this please. The easiest solution is to build the MIT App Inventor with my fixes and see what affect it has and then go from there. Lot of installs and learning for me but before I take that path want to see if I can narrow down on the issues with your help. Thanks

If you've set up your local build, it should be fairly trivial to apply the patches locally to test out the theory.


Good will do it, it might take a bit time, to figure out all the nuts and bolts. Thanks

I am using Windows 11, so enabled Hyper-V, installed Ubuntu, installed Vagrant and this is where I got stuck. If someone can kindly help me out I would be grateful:

I did do "snap info ant" and from what I read I think I might need to install Java or JS
I am just short of 1 command to be able to build app inventor.
I Googled around and I think for App Inventor using Virtual Box is a better alternative. If some can confirm then I will switch over to VB. Wasted a lot of time getting Hyper-V ;(

You can use either of the install commands listed, or you could also just download Apache Ant and put it on your PATH.

Note that while we provide the Vagrantfile to get started quickly, it's usually worth the effort to set up the toolchain on your native host (i.e., Windows) since the performance is typically much better. There is another thread in this category that includes step by step instructions on how to set up the build on Windows.

1 Like

Ah! Yes found it

Sorry for the delayed responses. I am travelling so once in a while I am getting time to logon. Will get this going.