要在字符串中包含一个单引号,就把 ' 字符写两遍,例如
messageText := '''sample text''';
Writeln(messageText)
这里第一个单引号开始字符串,接下来的一对表示一个引号。结尾也采用同样的方式。
其他转义字符可以写成 # 后面跟一个数字,例如
换行可以这样写:
messageText := 'Line break' + #13 + #10
或者直接写
messageText := 'Line break'#13#10
当然,使用平台对应的换行常量更好。
从英语翻译·查看原文A string can contain a single quote by doubling the ' character, for example
messageText := '''sample text''';
Writeln(messageText)
Here the first single quote opens the string, followed by a pair representing one quote. The ending uses the same arrangement.
Other escape characters can be written with # and a number, for instance
For a line break:
messageText := 'Line break' + #13 + #10
or simply
messageText := 'Line break'#13#10
Naturally, the platform-specific newline constant is the preferable choice.