👌
[Bug #21101] String#strip で Encoding::CompatibilityError が発生するバグ報告
[Bug #21101] Encoding::CompatibilityError when using String#strip
-
"test.dat" のファイルエンコーディングがISO 8859-1の時にドイツ語の文字(öとか)が含まれているとString#stripでEncoding::CompatibilityError` が発生するバグ報告
# error: Encoding::CompatibilityError
File.open('test.dat').each_line { |line| line.strip }
- Ruby 3.1 以前では問題なく動作していたけど Ruby 3.2 以降でエラーになるようになったみたいですね
- これなんですが Bug #18931: Inconsistent handling of invalid codepoints in String#lstrip and String#rstrip - Ruby master - Ruby Issue Tracking System で意図する変更がされた影響みたいです
-
encoding: Encoding::ISO_8859_1でエンコーディングを指定すれば解決できるということでこのチケットは閉じられています
Discussion