[ruby-dev:51081] [Ruby master Bug#12052] String#encode with xml option returns wrong result for totally non-ASCII-compatible encodings
From:
nobu@...
Date:
2021-07-11 22:46:51 UTC
List:
ruby-dev #51081
Issue #12052 has been updated by nobu (Nobuyoshi Nakada).
nagachika (Tomoyuki Chikanaga) wrote in #note-11:
> The multiple GitHub Actions environments show the failure of make check.
commit:391abc543cea118a9cd7d6310acadbfa352668ef is needed.
----------------------------------------
Bug #12052: String#encode with xml option returns wrong result for totally non-ASCII-compatible encodings
https://bugs.ruby-lang.org/issues/12052#change-92863
* 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/