为什么 F# 中三引号字符串中的换行符与 Environment.NewLine 不同?
Why is a newline in a triple-quotation string in F# not the same as Environment.NewLine?
F# 中的三引号字符串中的换行符似乎在 Windows(以及 Linux)上被转换为 LF,而不是 CRLF。但是,Environment.NewLine
是 Windows 上的 CRLF。
在 Windows:
let tripleQuotedString = """1
2
3"""
let concatenatedString = "1" + Environment.NewLine + "2" + Environment.NewLine + "3";;
printfn "%A" (Seq.toList tripleQuotedString) // yields ['1'; '0'; '2'; '0'; '3']
printfn "%A" (Seq.toList concatenatedString ) // yields ['1'; '3'; '0'; '2'; '3'; '0'; '3']
F# spec 中似乎没有提及。这是故意的设计决定吗?
三引号字符串的行尾与源代码文件行尾相同。
F# 中的三引号字符串中的换行符似乎在 Windows(以及 Linux)上被转换为 LF,而不是 CRLF。但是,Environment.NewLine
是 Windows 上的 CRLF。
在 Windows:
let tripleQuotedString = """1
2
3"""
let concatenatedString = "1" + Environment.NewLine + "2" + Environment.NewLine + "3";;
printfn "%A" (Seq.toList tripleQuotedString) // yields ['1'; '0'; '2'; '0'; '3']
printfn "%A" (Seq.toList concatenatedString ) // yields ['1'; '3'; '0'; '2'; '3'; '0'; '3']
F# spec 中似乎没有提及。这是故意的设计决定吗?
三引号字符串的行尾与源代码文件行尾相同。