From: "jpeterburs (Jonas Peterburs) via ruby-core" Date: 2025-01-30T13:02:44+00:00 Subject: [ruby-core:120843] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip Issue #21101 has been updated by jpeterburs (Jonas Peterburs). Thank you very much for the quick answer, that seems to have resolved my problem. ---------------------------------------- Bug #21101: Encoding::CompatibilityError when using String#strip https://bugs.ruby-lang.org/issues/21101#change-111709 * Author: jpeterburs (Jonas Peterburs) * Status: Open * ruby -v: 3.2.0 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- When opening an ISO 8859-1 encoded file containing a German letter (e.g. �), then parsing through each line and stripping whitespace using either `rstrip` or `strip` it raises an Error ( `lstrip` seams fine; I'd assume it skips stripping when there isn't any whitespace in front of the string). ``` ruby File.open('test.dat').each_line { |line| line.strip } # raises Encoding::CompatibilityError ``` I've tried this with multiple ruby versions. It was working as expected in these versions: - 2.7.8 - 3.0.0 - 3.0.7 - 3.1.0 - 3.1.1 - 3.1.2 - 3.1.3 - 3.1.4 - 3.1.5 - 3.1.6 And it didn't work in these: - 3.2.0 - 3.2.1 - 3.2.2 - 3.2.3 - 3.2.4 - 3.2.5 - 3.2.6 - 3.3.6 - 3.3.7 I didn't find anything in the Patch notes of ruby 3.2.0 about the changed behavior. Did I miss something? ---Files-------------------------------- test.dat (142 Bytes) -- 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/