ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120841] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip
@ 2025-01-30 12:00 jpeterburs (Jonas Peterburs) via ruby-core
  2025-01-30 12:56 ` [ruby-core:120842] " nobu (Nobuyoshi Nakada) via ruby-core
  2025-01-30 13:02 ` [ruby-core:120843] " jpeterburs (Jonas Peterburs) via ruby-core
  0 siblings, 2 replies; 3+ messages in thread
From: jpeterburs (Jonas Peterburs) via ruby-core @ 2025-01-30 12:00 UTC (permalink / raw)
  To: ruby-core; +Cc: jpeterburs (Jonas Peterburs)

Issue #21101 has been reported by jpeterburs (Jonas Peterburs).

----------------------------------------
Bug #21101: Encoding::CompatibilityError when using String#strip
https://bugs.ruby-lang.org/issues/21101

* 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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:120842] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip
  2025-01-30 12:00 [ruby-core:120841] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip jpeterburs (Jonas Peterburs) via ruby-core
@ 2025-01-30 12:56 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-01-30 13:02 ` [ruby-core:120843] " jpeterburs (Jonas Peterburs) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-01-30 12:56 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21101 has been updated by nobu (Nobuyoshi Nakada).


See https://bugs.ruby-lang.org/issues/18931.

You can add `encoding: Encoding::ISO_8859_1` keyword argument to tell the expected encoding.

----------------------------------------
Bug #21101: Encoding::CompatibilityError when using String#strip
https://bugs.ruby-lang.org/issues/21101#change-111708

* 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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:120843] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip
  2025-01-30 12:00 [ruby-core:120841] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip jpeterburs (Jonas Peterburs) via ruby-core
  2025-01-30 12:56 ` [ruby-core:120842] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-01-30 13:02 ` jpeterburs (Jonas Peterburs) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: jpeterburs (Jonas Peterburs) via ruby-core @ 2025-01-30 13:02 UTC (permalink / raw)
  To: ruby-core; +Cc: jpeterburs (Jonas Peterburs)

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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-30 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-30 12:00 [ruby-core:120841] [Ruby master Bug#21101] Encoding::CompatibilityError when using String#strip jpeterburs (Jonas Peterburs) via ruby-core
2025-01-30 12:56 ` [ruby-core:120842] " nobu (Nobuyoshi Nakada) via ruby-core
2025-01-30 13:02 ` [ruby-core:120843] " jpeterburs (Jonas Peterburs) via ruby-core

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).