is Serial.print() function can handle the escape character?

Im trying now to send sms. please reffer to comment

    while (!Serial1.find("OK"));
    while (!Serial1.find(">"));
    Serial1.println("my text my text\x1A");
    Serial.println("send x1A"); //I get this message, its meaning  we have sent text
    while (!Serial1.find("OK"));
    Serial.println("get OK");  //I didnt get OK, its meaning \x1A wasnt recognize as <^Z>

I know how to send ^Z with write() or with (char) casting but Im trying figure out how to send it by escape inside the println()
is it possible?

ESCape is 0x1B....

escape its mean escape symbol like "\r" and not ESC key :slight_smile:

issue resolved. print() can escape \x1A I just forgot to setup AT+CSCS="GSM"

thank you

\r is Carriage Return ??

\r is Carriage Return ??

What did you think it was?

OP was describing it as ‘an escape character’...

Ctrl-Z is '\x1b'

\r is Carriage Return ??

Of course, but OPs pointing out that the \ escapes the next character so \r doesn't print a "" followed by an "r".

Probably be more correct of him to say:

escape sequence like "\r"

... but I'm sure most readers know what was meant.

This is very useful to know:

print() can escape \x1A


I've only ever used the \ as \r and \t etc, not to escape the actual hex code. So thanks for that OP.

I’ve only ever used the \ as \r and \t etc, not to escape the actual hex code. So thanks for that OP.

You can also escape decimal and octal.

In fact, it is very hard to get far in C programming without using the former.

Ctrl-Z is ‘\x1b’

no it is 0x1A :wink:

You can also escape decimal

??? how ?

no it is 0x1A :wink:


1B is the ESC character ctrl-[, 1A is SUB, ctrl-Z.

Whoops, my bad.

Not many ascii tables show the ctrl- equivalents; this one does.

AWOL, as I know decimal can't be escaped :wink:

AWOL, as I know decimal can't be escaped :wink:

I use it all the time. char X = '\0';

in the print?

try print escaped decimal for example \32 inside the quotes print("\32"); I don't know how may be you know :wink:

As an aside, and sorry to go ot a bit, is there a "definitive" list of the single character escapes \t \r etc?

(I have, of course, Googled, but there's no way to know if a list is complete :wink: )

This line:


... prints a ! for the x21 but a box for decimal equivalent 33.

So, seems it needs to be hex to print?