Page 1 of 1
Quotes in strings without typing Chr(34) or #DQUOTE$
Posted: Mon Jul 11, 2016 1:51 am
by Dude
I just realized embedding inline quotes is possible by using
\" and the escape string operator (
~). Great stuff!
Code: Select all
a$=~"He said \"hello\" to his friends"
Debug a$
Re: Quotes in strings without typing Chr(34) or #DQUOTE$
Posted: Mon Jul 11, 2016 3:28 am
by Lunasole
Dude wrote:I just realized embedding inline quotes is possible by using \" and the escape string operator (~)
"in less than 2 years" ^^
Yes, that's one of nice things added to language recently, before I typically used ' instead of " and then ReplaceString()
Re: Quotes in strings without typing Chr(34) or #DQUOTE$
Posted: Mon Jul 11, 2016 4:13 am
by Dude
Lunasole wrote:"in less than 2 years"
Yes, it was added 9 months ago. But the manual doesn't explain much about it, except that escape characters are supported. I had no idea
\" was an escape character.

Re: Quotes in strings without typing Chr(34) or #DQUOTE$
Posted: Mon Jul 11, 2016 1:55 pm
by Kwai chang caine
Always good to know
Thanks

Re: Quotes in strings without typing Chr(34) or #DQUOTE$
Posted: Mon Jul 11, 2016 3:48 pm
by Keya
another day another new PB trick to add to the toolbelt!

and i had a look in the hex editor - the string is saved in escaped format (eg. \"Hi\" is saved in the exe as "Hi" not \"Hi\") , so no extra code is generated either (i guess that makes it a preprocessor thing?), nice and efficient in true Purebasic style
