@@ -131,9 +131,11 @@ defmodule IO do
131
131
The `device` is iterated as specified by the `line_or_chars` argument:
132
132
133
133
* if `line_or_chars` is an integer, it represents a number of bytes. The device is
134
- iterated by that number of bytes.
134
+ iterated by that number of bytes. This should be the preferred mode for reading
135
+ non-textual inputs.
135
136
136
137
* if `line_or_chars` is `:line`, the device is iterated line by line.
138
+ CRFL newlines ("\r \n ") are automatically normalized to "\n ".
137
139
138
140
* if `line_or_chars` is `:eof` (since v1.13), the device is iterated until `:eof`.
139
141
If the device is already at the end, it returns `:eof` itself.
@@ -184,9 +186,11 @@ defmodule IO do
184
186
The `device` is iterated as specified by the `line_or_chars` argument:
185
187
186
188
* if `line_or_chars` is an integer, it represents a number of bytes. The device is
187
- iterated by that number of bytes.
189
+ iterated by that number of bytes. This should be the preferred mode for reading
190
+ non-textual inputs.
188
191
189
192
* if `line_or_chars` is `:line`, the device is iterated line by line.
193
+ CRFL newlines ("\r \n ") are automatically normalized to "\n ".
190
194
191
195
* if `line_or_chars` is `:eof` (since v1.13), the device is iterated until `:eof`.
192
196
If the device is already at the end, it returns `:eof` itself.
@@ -596,8 +600,9 @@ defmodule IO do
596
600
`Collectable`, allowing it to be used for both read
597
601
and write.
598
602
599
- The `device` is iterated by the given number of characters or line by line if
600
- `:line` is given.
603
+ The `device` is iterated by the given number of characters
604
+ or line by line if `:line` is given. In case `:line` is given,
605
+ "\r \n " is automatically normalized to "\n ".
601
606
602
607
This reads from the IO as UTF-8. Check out
603
608
`IO.binstream/2` to handle the IO as a raw binary.
@@ -650,14 +655,17 @@ defmodule IO do
650
655
`Collectable`, allowing it to be used for both read
651
656
and write.
652
657
653
- The `device` is iterated by the given number of bytes or line by line if
654
- `:line` is given. This reads from the IO device as a raw binary.
658
+ The `device` is iterated by the given number of bytes or line
659
+ by line if `:line` is given. In case `:line` is given, "\r \n "
660
+ is automatically normalized to "\n ". Passing the number of bytes
661
+ should be the preferred mode for reading non-textual inputs.
655
662
656
663
Note that an IO stream has side effects and every time
657
664
you go over the stream you may get different results.
658
665
659
- Finally, do not use this function on IO devices in Unicode
660
- mode as it will return the wrong result.
666
+ This reads from the IO device as a raw binary. Therefore,
667
+ do not use this function on IO devices in Unicode mode as
668
+ it will return the wrong result.
661
669
662
670
`binstream/0` has been introduced in Elixir v1.12.0,
663
671
while `binstream/2` has been available since v1.0.0.
0 commit comments