How does one escape characters in Delphi string

Delphi strings use single quotes, for example 'a valid string'. How does one specify the ' character within a literal string? How would one refer to the null byte (Unicode code point U+0000)?

Answers


To add a single quote to a string you do 2 ' marks e.g.

str := '''test string''';
Writeln(str)

In the string above you have the normal single quotation to start a string and then two for the single quote. Same goes for the end of the string.

You can also use # followed by a number for other escape character e.g. For a new line:

str := 'Newline' + #13 + #10

or just

str := 'Newline'#13#10

Of course using the platform dependant constant for new line is better


Need Your Help

mvc return Json() vs. JSON based Web Service

asp.net-mvc web-services json json.net

I want to expose a service on my site that any users can call and get a JSON response. In the end, I want the users to be using this service as much as possible.

How to get iPhone name from osx terminal?

iphone osx shell terminal usb

Writing a simple hobby bash script to download photos from iPhone and then copy them to my server which is automatically backed up. I'd like to find the name of the iPhone that I currently have plu...