Sending String with inverted commas as part of it

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Sending String with inverted commas as part of it

Post by jollybv »

Hi Guys

How would I send a string like this AT+CSCS="GSM" with the inverted commas included

I have tried
String = "AT+CSCS="
String = String + ""GSM""

But this formula is not right

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Sending String with inverted commas as part of it

Post by Benj »

Hello,

This is the way I might do it.

"AT+CSCS=\"GSM\""

The slashes in front of the speech mark allows it to be escaped.
https://en.wikipedia.org/wiki/Escape_sequences_in_C

User avatar
jollybv
Flowcode v5 User
Posts: 374
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times
Contact:

Re: Sending String with inverted commas as part of it

Post by jollybv »

Hi Ben

Thanks for the reply i managed to sort it looking back at some old code
send = "AT+CSCS="
send = send + "\""
send = send + "GSM"
send = send + "\""

But I will use your code as it is way less code

Post Reply