Why is a newline in a triple-quotation string in F# not the same as Environment.NewLine?

Viewed 98

It appears that newlines in a triple-quote string in F# are translated to LF on Windows (as well as Linux), not CRLF. However, Environment.NewLine is CRLF on Windows.

On Windows:

let tripleQuotedString = """1
2
3"""
let concatenatedString = "1" + Environment.NewLine + "2" + Environment.NewLine + "3";;
printfn "%A" (Seq.toList tripleQuotedString) // yields ['1'; '\010'; '2'; '\010'; '3']
printfn "%A" (Seq.toList concatenatedString ) // yields ['1'; '\013'; '\010'; '2'; '\013'; '\010'; '3']

This doesn't appear to be mentioned in the F# spec. Is it a deliberate design decision?

1 Answers

Triple quote string's line ending is same as source code file line ending.

Related