什么是 Delphi Prism LineFeed
Delphi Prism 中 C# 的 \n 和 Visual Basic 的 vbCRLF 或 vbNewLine 等效项是什么?我必须使用Environment.NewLine吗?
What is the equivalent of C#'s \n and Visual Basic's vbCRLF or vbNewLine in Delphi Prism? Do I have to use Environment.NewLine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Environment.NewLine 实际上是最好用的,因为它应该是独立于平台的。顺便说一句,本指南也适用于 C#。
Environment.NewLine is actually the best thing to use, as it is supposed to be platform independent. This guidance goes for C# as well, by the way.
MyString := '一'#13#10'二';相当于 c# 的“One\r\nTwo”。
MyString := 'One'#13#10'Two'; would be the equivalent of c#'s "One\r\nTwo".
适当的换行符不是运行时平台或语言选择的问题,而是输出文件的源(或预期接收者)的问题。如果该文件完全供应用程序私人使用(仅由应用程序读取/写入),那么您可以使用您喜欢的任何字符来分隔行。
如果您需要与应用程序本身之外的某些方或进程交换文件,那么该方的需求很可能决定您应该期望(并且期望)使用什么作为换行符。
然而,要回答实际问题,vbCRLF 的等价物是(作为文字值)#13#10 以及 vbNewLine 的等价物将是 #10 (#13 是 CR 的字符代码,#10 是 LF< /强>)。
The appropriate new line character is not a question of runtime platform or language choice, it is a question of the source (or intended recipient) of the output file. If the file is entirely for private use by an application (only ever read/written by the app) then you can use whatever character you like to delimit lines.
If you need to exchange the file with some party or process outside of the application itself then the needs of that other party may well dictate what you should expect (and are expected) to use as the new line character.
To answer the actual question as put however, the equivalent of vbCRLF is (as a literal value) #13#10 and the equivalent of vbNewLine would be #10 (#13 is the char code for CR and #10 for LF).