Skip to content

Commit 9e687da

Browse files
authored
Fix IO.read/2 docs: integer count is in characters, not bytes (#15549)
`IO.read/2` is the Unicode-safe reader and delegates an integer count to `:io.get_chars/3`, which counts characters, not bytes. The docs were copied from `IO.binread/2` (the byte-oriented, Unicode-unsafe reader), so they incorrectly described the integer argument as a number of bytes and carried binread/2's "preferred mode for reading non-textual inputs" note. This also contradicted read/2's own return description, which already documents the result as "the output characters". Assisted-by: Claude Code:claude-opus-4-8 Signed-off-by: nseaSeb <nseaprotector@gmail.com>
1 parent 681a9ee commit 9e687da

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/elixir/lib/io.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ defmodule IO do
152152
153153
The `device` is iterated as specified by the `line_or_chars` argument:
154154
155-
* if `line_or_chars` is an integer, it represents a number of bytes. The device is
156-
iterated by that number of bytes. This should be the preferred mode for reading
157-
non-textual inputs.
155+
* if `line_or_chars` is an integer, it represents a number of characters. The device
156+
is iterated by that number of characters.
158157
159158
* if `line_or_chars` is `:line`, the device is iterated line by line.
160159
CRLF newlines ("\r\n") are automatically normalized to "\n".

0 commit comments

Comments
 (0)