From: duerst@... Date: 2021-07-04T02:02:06+00:00 Subject: [ruby-dev:51078] [Ruby master Bug#12052] String#encode with xml option returns wrong result for totally non-ASCII-compatible encodings Issue #12052 has been updated by duerst (Martin Dürst). nagachika (Tomoyuki Chikanaga) wrote in #note-9: > The test introduced at e62cccaeb0986d43480bccbd365cb20056bda4d7 failed on almost all environments. > I reverted the changesets for the time being. @nagachika: Can you tell us exactly what, or how, things failed? It's very difficult to imagine a reason for such a failure, because I don't know of any recent (e.g. 2.7) changes to the involved code (i.e. transcode.c). ---------------------------------------- Bug #12052: String#encode with xml option returns wrong result for totally non-ASCII-compatible encodings https://bugs.ruby-lang.org/issues/12052#change-92754 * 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/