coldfusion记事本中的换行

coldfusion记事本中的换行,coldfusion,coldfusion-8,coldfusion-9,Coldfusion,Coldfusion 8,Coldfusion 9,我无法说服自己为什么不能用coldfusion打破记事本上的界线 这是我的代码 <cfscript> msg = "ppshein<CR>Coldfusion Developer<CR>Currently working in Singapore"; currentPath = getCurrentTemplatePath(); currentDirectory = getDirectoryFromPath(currentPath);

我无法说服自己为什么不能用coldfusion打破记事本上的界线

这是我的代码

<cfscript>
    msg = "ppshein<CR>Coldfusion Developer<CR>Currently working in Singapore";
    currentPath = getCurrentTemplatePath();
    currentDirectory = getDirectoryFromPath(currentPath);
    chgMsg = ReReplace(msg, "<CR>", "<CR>\r\n", "ALL");
    FileWrite("#currentDirectory#\myfile.txt", "#chgMsg#");
    return "successfully generated";
</cfscript>

msg=“ppsheinColdfusion developer目前正在新加坡工作”;
currentPath=getCurrentTemplatePath();
currentDirectory=getDirectoryFromPath(currentPath);
chgMsg=重新替换(msg,“,\r\n”,“全部”);
文件写入(#currentDirectory#\myfile.txt“,#chgMsg#”);
返回“生成成功”;
我在上面运行的代码并打开myfile.txt,它就这样发生了

ppshein<CR>Coldfusion Developer<CR>Currently working in Singapore
ppsheinColdfusion developer目前在新加坡工作
我想要的是

ppshein<CR>
Coldfusion Developer<CR>
Currently working in Singapore
ppshein
Coldfusion显影剂
目前在新加坡工作

如果您有任何意见,我们将不胜感激。

您不认为需要在此处重新替换,而且您的替换字符串不正确--CF无法识别此格式。试试这个:

chgMsg = Replace(msg, "<CR>", chr(13)&chr(10), "ALL");
chgMsg=Replace(msg,”,chr(13)和chr(10),“ALL”);
UPD。让我试着优化一下整个代码块

<cfscript>
    msg = "ppshein<CR>Coldfusion Developer<CR>Currently working in Singapore";
    chgMsg = Replace(msg, "<CR>", chr(13)&chr(10), "ALL");
    FileWrite(ExpandPath("./myfile.txt"), chgMsg);
    return "successfully generated";
</cfscript>

msg=“ppsheinColdfusion developer目前正在新加坡工作”;
chgMsg=替换(msg,”,chr(13)和chr(10),“全部”);
文件写入(ExpandPath(“./myfile.txt”)、chgMsg;
返回“生成成功”;

更干净、更容易阅读。

天哪。。!!正确的。我给错代码了。实际代码如下。chgMsg=替换(msg,“,”&chr(13),“全部”);我忘了在chr(13)后面加chr(10)。谢谢你抽出时间。