为什么在Delphi中可以使用抑扬符来控制字符,这是一个好主意吗? [英] Why can the circumflex sign be used for control chars in Delphi and is it a good idea?

查看:81
本文介绍了为什么在Delphi中可以使用抑扬符来控制字符,这是一个好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚以一种奇怪的语法遇到了一个关于SO的答案:

I just came across an answer on SO with a curious syntax:

How do I include a newline character in a string in Delphi?

MyString:='Hello,'+ ^ M + ^ J +'world!';

我已经使用Delphi几年了,但是我不知道您可以使用抑扬符来控制字符。

I've been using Delphi for several years now, but I didn't know you could use the circumflex sign for control characters.

这是一个剩余的吗?从早期的Delphi或Turbo Pascal时代开始?

Is this just a left over from the early Delphi or Turbo Pascal days?

现在应该使用吗?

PS:我是没有询问有关换行符的建议,有sLineBreak和原始问题中讨论的其他方法。

PS: I'm not asking about advice on the line break characters, there is sLineBreak and other methods as discussed in the original question.

推荐答案

是的是昔日的遗产。

不,您不应该养成使用此功能的习惯。请记住,读取代码的次数要多于编写代码的次数。始终想起您的读者,他们很可能不知道该语法的含义。

And no you should not get into the habit of using this feature. Remember that code is read more often than it is written. Always think of your readers who most likely won't know what that syntax means.

这篇关于为什么在Delphi中可以使用抑扬符来控制字符,这是一个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆