How does one escape characters in Delphi string

主宰稳场 提交于 2019-11-28 09:35:31
Jamie

To add a single quote to a string, you include two ' 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-dependent constant for newline is better.

To answer the last part of the question, you can use

#$0000   

To add U+0000

This way you can add the other Unicode chars too. (Be sure to use a font that can display those characters.)

vrad

For ' character put it twice. For example: 'Don''t'. Null byte type as #0.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!