If I understand the docs correctly, the OS-specific handling is in
open-input-file, but it is not the default.
Here is an alternative to read-line that preserves line endings:
#lang racket/base
;; my-read-line : InputPort -> String
;; Like read-line, but preserves line ending.
;; Fails
Suppose I have two files that are identical, except one ends in a newline
and the other does not. If I use `read-line` to read the successive lines
of this file, because it swallows the line separators, there is no way to
tell them apart. E.g., these two strings
"a
b"
and
"a
b
"
read using
2 matches
Mail list logo