本文介绍了如何在 ColdFusion 中的字符串中写入换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我正在通过以下两种方法之一在字符串中添加换行符:
Currently I'm putting newlines in strings through one of these two methods:
<cfset someStr="This is line 1" & Chr(10) & "This is line 2" & Chr(10) & "This is line 3" />
或
<cfset NL=Chr(10) />
<cfset someStr="This is line 1#NL#This is line 2#NL#This is line 3" />
还有什么更像 Java/C++ 的方式吗?我的意思更像是这样的:
Is there anything more like the Java/C++ way? Something more like this I mean:
<cfset someStr="This is line 1
This is line 2
This is line 3" />
推荐答案
你的方法是对的.CF 中不支持 或 .来自 实时文档
Your way is correct. There is no support for or in CF. From the Live Docs
- Chr(10) 返回换行符
- Chr(13) 返回一个回车符
- 两个字符的字符串 Chr(13) &Chr(10) 返回一个 Windows 换行符
这篇关于如何在 ColdFusion 中的字符串中写入换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!