How escape character works

I have made a String variable, 'proName' .. with 15 characters stored in EEPROM of Arduino Mega.
I want to send this String to Nextion display text object, since the text to be sent is not Static..I am trying to use the escape character ( " ) before the String variable like this..

nexSerial.print("t0.txt= "); nexSerial.print(""" String(proName));
endMessage(); --OR--- t0.setText(""" String(proName));

Here endMessage() sends three 0xFF.
I tried various combinations of quote mark before-after 'back slash+quote' , different places of escape character but nothing works.
Any help will be highly appreciated please.
-Arun

I am sorry to see the message I posted does not contain the back slash anywhere, that was included in my draft.
I am trying..
nexSerial.print("t0.txt= ");
nextSerial.print(""" String(proName));
endMessage();

That's because you need to escape it by using 2 backslashes !

"\\"

displays as

"\"

You could do that without using an escape characters at all. Try this:

nexSerial.print("t0.txt= ""); 
nexSerial.print(proName);
nexSerial.print("""); 
endMessage();

but better to escape quotation by \

nexSerial.print("t0.txt= \""); 
nexSerial.print(proName);
nexSerial.print("\""); 
endMessage();

the compiler would bark at this, wouldn't it?

1 Like

Or as I used to do sometime ago...

nexSerial.print("t0.txt= \""); 
nexSerial.print(proName);
nexSerial.print("\x22\xFF\xFF\xFF");

You can not store a String object in eeprom. You will need to store the characters of the underlying character array.

Technically you can but it’s useless as what you write is the pointer address, the size and length, not the actual text which is « outside » the instance

:slight_smile:

1 Like

Yes sure I stored the chacters in the eeprom's 15 locations...anyway my problem of sending a String variable from arduino to nextion has been resolved using the escape charcter backslash and double quote..anyway thanks for ur support...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.