[ruby-dev:47993] [ruby-trunk - Bug #9415] Strings#codepoints doesn't respect BOM on UTF-{16, 32} pseudo encodings
From:
naruse@...
Date:
2014-02-21 08:34:51 UTC
List:
ruby-dev #47993
Issue #9415 has been updated by Yui NARUSE.
Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: REQUIRED to 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: DONE
r45074
----------------------------------------
Bug #9415: Strings#codepoints doesn't respect BOM on UTF-{16,32} pseudo encodings
https://bugs.ruby-lang.org/issues/9415#change-45330
* Author: Nobuyoshi Nakada
* Status: Closed
* Priority: Normal
* Assignee: Yui NARUSE
* Category: M17N
* Target version: current: 2.2.0
* ruby -v: -
* Backport: 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: DONE
----------------------------------------
`String#codepoints`が`UTF-16`、`UTF-32`でのBOMを考慮していません。
```
$ ruby -e 'puts "%x" % "\u{feff}".encode("UTF-16BE").force_encoding("UTF-16").codepoints'
feff
$ ruby -e 'puts "%x" % "\u{feff}".encode("UTF-16LE").force_encoding("UTF-16").codepoints'
fffe
```
`String#ord`なども同様です。
```
$ ruby -e 'printf "%x\n", "\u{feff}".encode("UTF-16BE").force_encoding("UTF-16").ord'
feff
$ ruby -e 'printf "%x\n", "\u{feff}".encode("UTF-16LE").force_encoding("UTF-16").ord'
fffe
```
--
http://bugs.ruby-lang.org/