New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected result of scala.io.Source.fromFile(...).mkString(",") evaluation #6592
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6592?orig=1 |
Alexei Tereschenko (aytereschenko) said (edited on Oct 30, 2012 1:47:35 PM UTC): object Test {
def main(args: Array[String]) = {
println(scala.io.Source.fromFile("/tmp/test.txt").mkString(","))
println(scala.io.Source.fromFile("/tmp/test2.txt").mkString(","))
}
} then I receive the following output:
|
@JamesIry said: |
1 similar comment
@JamesIry said: |
@som-snytt said: The "\r," sequence places a comma in the first column of the terminal. The difference between the two strings is that one ends in whitespace, so REPL displays it in quotes; the open quote is overstruck instead of the first char of text. scala> scala.io.Source.fromFile("test2.txt").mkString(",") map { case '\r' => '*' case c => c }
res0: String =
l,i,n,e,1,*,
,l,i,n,e,2,*,
,l,i,n,e,3
scala> "a b c"
res1: String = a b c
scala> "a b c "
res2: String = "a b c " |
It looks like CR echo progressed in 2.13 because of jline upgrade?
|
I've 2 files that have only one difference - "\r\n" sequence in the test.txt
[vladimir@vladimir tmp]$ cat test.txt
line1
line2
line3
[vladimir@vladimir tmp]$ cat test2.txt
line1
line2
line3[vladimir@vladimir tmp]$
I try to execute in the REPL:
scala> scala.io.Source.fromFile("/tmp/test.txt").mkString(",")
res17: String =
,l,i,n,e,1,
,l,i,n,e,2,
,l,i,n,e,3,
"
scala> scala.io.Source.fromFile("/tmp/test2.txt").mkString(",")
res18: String =
,,i,n,e,1,
,l,i,n,e,2,
,l,i,n,e,3
scala>
As you can see, for test2.txt file the first "l" character ommited. I think, that it isn't expected behaviour.
The text was updated successfully, but these errors were encountered: