如何在ColdFusion中的字符串中写一个换行符? [英] How can I write a newline in a string in ColdFusion?

查看:152
本文介绍了如何在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\nThis is line 2\nThis is line 3" />


推荐答案

在CF中不支持\\\
或\r。从即时文档

Your way is correct. There is no support for \n or \r in CF. From the Live Docs



  • Chr(10)返回换行字符

  • Chr 13)返回一个回车字符

  • 两个字符的字符串Chr(13)& Chr(10)返回Windows换行符。

这篇关于如何在ColdFusion中的字符串中写一个换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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