Как насчет одной строки! Это в C #.
Xmas(){Console.WriteLine("On the first day of Christmas,\r\nmy true love sent to me\r\nA partridge in a pear tree.\r\n\r\nOn the second day of Christmas,\r\nmy true love sent to me\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the third day of Christmas,\r\nmy true love sent to me\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the fourth day of Christmas,\r\nmy true love sent to me\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the fifth day of Christmas,\r\nmy true love sent to me\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the sixth day of Christmas,\r\nmy true love sent to me\r\nSix geese a-laying,\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the seventh day of Christmas,\r\nmy true love sent to me\r\nSeven swans a-swimming,\r\nSix geese a-laying,\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the eighth day of Christmas,\r\nmy true, love sent to me\r\nEight maids a-milking,\r\nSeven swans a-swimming,\r\nSix geese a-laying,\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the ninth day of Christmas,\r\nmy true love sent to me\r\nNine ladies dancing,\r\nEight maids a-milking,\r\nSeven swans a-swimming,\r\nSix geese a-laying,\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the tenth day of Christmas,\r\nmy true love sent to me\r\nTen lords a-leaping,\r\nNine ladies dancing,\r\nEight maids a-milking,\r\nSeven swans a-swimming,\r\nSix geese a-laying,\r\nfive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the eleventh day of Christmas,\r\nmy true love sent to me\r\nEleven pipers piping,\r\nTen lords a-leaping,\r\nNine ladies dancing,\r\nEight maids a-milking,\r\nSeven swans a-swimming,\r\nSix geese a-laying\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree.\r\n\r\nOn the twelfth day of Christmas,\r\nmy true love sent to me\r\nTwelve drummers drumming,\r\nEleven pipers piping,\r\nTen lords a-leaping,\r\nNine ladies dancing,\r\nEight maids a-milking,\r\nSeven swans a-swimming,\r\nSix geese a-laying,\r\nFive golden rings,\r\nFour calling birds,\r\nThree French hens,\r\nTwo turtle doves,\r\nAnd a partridge in a pear tree!");}
Ваш путь правильный. В CF нет поддержки \ n или \ r. Из Live Docs
- Chr (10) возвращает символ перевода строки
- Chr (13) возвращает символ возврата каретки
- Двухсимвольная строка Chr (13) & Chr (10) возвращает символ Windows newline
Если вы занимаетесь разработкой, не зависящей от платформы, вы можете сделать:
<cfset NL = CreateObject("java", "java.lang.System").getProperty("line.separator")>
Например, в вашем application.cfm / cfc
или в другом месте высокого уровня и использовать это.
Я использую это:
<cfset br = "#chr(13)##chr(10)#">
<cfset someStr="This is line 1#br#This is line 2#br#This is line 3" />
Не прямо в CF, я оставлю это на усмотрение парней из CF-Java, чтобы сказать, можете ли вы использовать Java-метод непосредственно в CF var для достижения желаемого, но ...
Вы можете использовать cfsavecontent для вставки естественных разрывов строк в:
<cfsavecontent variable="someStr">
This is line 1
This is line 2
This is line 3
</cfsavecontent>
Затем проверьте это с помощью:
<cfoutput>
<pre>#Trim(someStr)#</pre>
</cfoutput>
Обратите внимание, что Trim () позволяет избавиться от первого и последнего разрывов строк, если они вам не нужны. .
Мне было интересно, сработает ли что-то вроде этого:
<cfset str = CreateObject("java", "java.lang.String").init("Line 1\nLine 2\nLine 3")>
<cfoutput>
<pre>#str#</pre>
</cfoutput>
Увы, нет: O (