2

I am working to send SMS using java program.

The AT command is supping as a string. But the string format should be like AT+CMGS="+33146290800"<CR>Please call me soon.<ctrl-Z>.

I have to create string with the Carriage Return and CTRL-Z character.

If I add 0x0D and 0x1A with the string.

output:

AT+CMGS="+33146290800"13Please call me soon.26

How can I achieve the task? Can anyone help me to find a way out.

Community
  • 1
  • 1
Shantanu Banerjee
  • 1,417
  • 6
  • 31
  • 51

1 Answers1

9

To get this string:

"+33146290800"<CR>Please call me soon.<ctrl-Z>

You use this string literal:

String s = "\"+33146290800\"\rPlease call me soon.\u001A";

\" is the Java string literal escape sequence for a double quote, \r is escape sequence a carriage return, and \u0026 is the Java string literal Unicode escape sequence for character x1A (decimal 26), e.g., Ctrl+Z. More to explore in the JLS.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875