From: "javanthropus (Jeremy Bopp) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "javanthropus (Jeremy Bopp)" <noreply@ruby-lang.org>
Subject: [ruby-core:120059] [Ruby master Bug#20924] IO#readline ignores the limit argument when the encoding is UTF-32LE and the limit would split a character
Date: Fri, 29 Nov 2024 16:35:53 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-110797.20241129163552.692@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20924.20241129160708.692@ruby-lang.org>
Issue #20924 has been updated by javanthropus (Jeremy Bopp).
Note that replacing `#readline` with `#gets` in the examples causes the issue to be seen in all Ruby versions, including 3.3.6.
----------------------------------------
Bug #20924: IO#readline ignores the limit argument when the encoding is UTF-32LE and the limit would split a character
https://bugs.ruby-lang.org/issues/20924#change-110797
* Author: javanthropus (Jeremy Bopp)
* Status: Open
* ruby -v: ruby 3.4.0dev (2024-11-28T12:38:16Z master 3af1a04741) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
```ruby
require 'tempfile'
Tempfile.open(binmode: true, encoding: 'utf-32le') do |f|
f.write('0123456789')
f.rewind
# A limit that would truncate a character becomes completely ignored
f.readline(3).bytesize # => 40; should be 4
end
Tempfile.open(binmode: true, encoding: 'utf-32le') do |f|
f.write('0123456789')
f.rewind
# A limit on character boundaries is respected
f.readline(4).bytesize # => 4
end
Tempfile.open(encoding: 'utf-8:utf-32le') do |f|
f.write('0123456789')
f.rewind
# A limit that would truncate a character becomes completely ignored
f.readline(3).bytesize # => 40; should be 4
end
Tempfile.open(encoding: 'utf-8:utf-32le') do |f|
f.write('0123456789')
f.rewind
# A limit on character boundaries is respected
f.readline(4).bytesize # => 4
end
```
This doesn't happen with UTF-32BE. This also doesn't happen in Ruby 3.3, but it does happen in 3.4-dev and Ruby 3.0 - 3.2.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
next prev parent reply other threads:[~2024-11-29 16:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 16:07 [ruby-core:120058] " javanthropus (Jeremy Bopp) via ruby-core
2024-11-29 16:35 ` javanthropus (Jeremy Bopp) via ruby-core [this message]
2024-12-15 9:33 ` [ruby-core:120248] " nagachika (Tomoyuki Chikanaga) via ruby-core
2025-01-15 1:53 ` [ruby-core:120686] " k0kubun (Takashi Kokubun) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-110797.20241129163552.692@ruby-lang.org \
--to=ruby-core@ml.ruby-lang.org \
--cc=noreply@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).