Перерыв линии в блокноте с ColdFusion
-
27-09-2019 - |
Вопрос
Я не могу убедить, почему я не могу сломать линию в блокноте с 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>
что я бежит выше кодирования и открыть myfile.txt, это происходит так
ppshein<CR>Coldfusion Developer<CR>Currently working in Singapore
Что я хочу, это
ppshein<CR>
Coldfusion Developer<CR>
Currently working in Singapore
Любые комментарии будут оценены.
Решение
Не думайте, что вам нужно rereplace здесь, плюс ваша замена строки неверна - CF не распознает этот формат. Попробуй это:
chgMsg = Replace(msg, "<CR>", 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>
Немного более чистый и легко читать.
Не связан с StackOverflow