Skip to content

Line separator#307

Open
Antimonit wants to merge 2 commits into
robfletcher:mainfrom
Antimonit:line-separator
Open

Line separator#307
Antimonit wants to merge 2 commits into
robfletcher:mainfrom
Antimonit:line-separator

Conversation

@Antimonit

Copy link
Copy Markdown

Running on a Windows machine, any tests that check multi-line string equality fail:

Screenshot 2025-06-11 163421

These tests fail only due to a difference in line separators:

Screenshot 2025-06-11 162957

Even on Windows, even when the source code file itself contains CR/LF endings:

image

the internal structures used by Java contain just LF.

A small sanity check test:

val multiLine = """AA
AA"""
val lf = "AA\nAA"
val crlf = "AA\r\nAA"

fun String.bytes() = this.toByteArray().joinToString()

println(multiLine.bytes()) // 65, 65, 10, 65, 65
println(lf.bytes())        // 65, 65, 10, 65, 65
println(crlf.bytes())      // 65, 65, 13, 10, 65, 65

The actual multi-line strings contain just \n rather than \r\n.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant