From: nagachika00@... Date: 2021-07-04T08:27:36+00:00 Subject: [ruby-dev:51079] [Ruby master Bug#12052] String#encode with xml option returns wrong result for totally non-ASCII-compatible encodings Issue #12052 has been updated by nagachika (Tomoyuki Chikanaga). The multiple GitHub Actions environments show the failure of make check. The error messages are all the same. Ubuntu: https://github.com/ruby/ruby/runs/2977522707 macOS: https://github.com/ruby/ruby/runs/2977522761 MinGW: https://github.com/ruby/ruby/runs/2977522628 ``` 1) Failure: TestTranscode#test_encode_xml_multibyte [/home/runner/work/ruby/ruby/src/test/ruby/test_transcode.rb:140]: failed encoding UTF-16LE to UTF-16LE with xml: :text. <"<>"> expected but was <"<\u0000>\u0000">. ``` ---------------------------------------- Bug #12052: String#encode with xml option returns wrong result for totally non-ASCII-compatible encodings https://bugs.ruby-lang.org/issues/12052#change-92757 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Priority: Normal * Assignee: akr (Akira Tanaka) * Backport: 2.7: REQUIRED, 3.0: REQUIRED ---------------------------------------- `String#encode`をASCII非互換エンコーディングから同じエンコーディングへ、`xml:`オプション付きで呼ぶとおかしな結果を返します。 バイナリとして変換してしまっているようです。 ```ruby p "<\0>\0".encode("utf-16le", "utf-16le", xml: :text) #=> "\u6C26\u3B74\u2600\u7467;" ``` -- https://bugs.ruby-lang.org/