Actions
Bug #20566
closedstring << 0xC2 should raise a RangeError if the string encoding is Encoding::ASCII
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0preview1 (2024-05-16 master 9d69619623) [x86_64-linux]
Description
I noticed that appending extended ASCII characters (0x80 - 0xff) works when the String's encoding is Encoding::ASCII, as well as Encoding::ASCII_8BIT. I was under the impression that Encoding::ASCII only covers the regular ASCII character set (0x00 - 0x7F). I believe appending 0xC2 to a String with Encoding::ASCII should raise a RangeError.
Steps To Reproduce¶
str = String.new(encoding: Encoding::ASCII)
str << 0xC2
Expected Result¶
RangeError: character 194 is out of range
Actual Result¶
"\xC2"
Actions
Like0
Like0Like0Like0