From: Tanaka Akira Date: 2013-07-18T18:07:26+09:00 Subject: [ruby-core:56073] Re: [ruby-trunk - Bug #8653][Open] Unexpected result of String#succ with utf-16 and utf-32 string. 2013/7/18 phasis68 (Heesob Park) : > Bug #8653: Unexpected result of String#succ with utf-16 and utf-32 string. > https://bugs.ruby-lang.org/issues/8653 > I found the result of String#succ of UTF-16LE encoded string is incorrect. > > As a result, Range of UTF-16LE encoded string show some unexpected behavior. I don't say the bahavior is incorrect. % ruby -e 'p "A".encode("UTF-16LE").force_encoding("ASCII-8BIT")' "A\x00" % ruby -e 'p "A".encode("UTF-16LE").succ.force_encoding("ASCII-8BIT")' "A\x01" % ruby -e 'p "B".encode("UTF-16LE").force_encoding("ASCII-8BIT")' "B\x00" % ruby -e 'p "B".encode("UTF-16LE").succ.force_encoding("ASCII-8BIT")' "B\x01" String#succ generates the bytewise lexicographicaly next characters successfully. I agree that is not intuitive. But it is very difficult to define String#succ in encoding neutral way. -- Tanaka Akira