From: nobu@... Date: 2016-02-05T02:50:29+00:00 Subject: [ruby-dev:49493] [Ruby trunk Bug#12052] String#encode with xml option returns wrong result Issue #12052 has been reported by Nobuyoshi Nakada. ---------------------------------------- Bug #12052: String#encode with xml option returns wrong result https://bugs.ruby-lang.org/issues/12052 * Author: Nobuyoshi Nakada * Status: Assigned * Priority: Normal * Assignee: Akira Tanaka * ruby -v: * Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED, 2.3: 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/