
Issue #20566 has been updated by nobu (Nobuyoshi Nakada). It is a [spec](https://bugs.ruby-lang.org/issues/18973#note-6). ---------------------------------------- Bug #20566: string << 0xC2 should raise a RangeError if the string encoding is Encoding::ASCII https://bugs.ruby-lang.org/issues/20566#change-108756 * Author: postmodern (Hal Brodigan) * Status: Open * ruby -v: ruby 3.4.0preview1 (2024-05-16 master 9d69619623) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- 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 ```ruby str = String.new(encoding: Encoding::ASCII) str << 0xC2 ``` ### Expected Result ``` RangeError: character 194 is out of range ``` ### Actual Result ```ruby "\xC2" ``` -- https://bugs.ruby-lang.org/