Home Using quote inside strings in Delphi
Reply: 4

Using quote inside strings in Delphi

Arthur Published in 2009-02-25 20:45:51Z

Possible Duplicate:
How does one escape characters in Delphi string

In Delphi a string is contained within a pair of ' but I need to use ' in my string... and when I use one it brings a end to the entire string identification.

'inside string ' but this bit is outside' inside again' and the end

Is there some symbol that removes the coding affect of the next character?

Community Reply to 2017-05-23 10:30:36Z

You need another quote to escape a quote:

Writeln('I''m in your head'); //prints: I'm in your head
Writeln(''''); //prints: '

See also this question.

zendar Reply to 2009-02-25 21:01:44Z

Delphi has QuotedStr() function that adds quotes around string and does escaping of apostrophes in string automatically.

procedure MyForm.MyProc;
var str : string;
  str = QuotedStr(MyForm.Edit1);

QuotedStr() will put contents of edit field into apostrophes. If edit field contains apostrophes, they will be properly escaped.

Community Reply to 2017-05-23 11:47:32Z

Similar Question here:

How does one escape characters in Delphi string

Covers single quotes and escape characters

bluish Reply to 2013-08-27 13:24:02Z

I usually use the QuotedStr function to fix strings with quotes in them. Also, I often find it helpful to have defined constants like CRLF and TAB that represent #13#10 and #9 respectively. Sometimes, it seems clearer (to me at least) to do something similar with quotes.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.421549 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO