From: Tanaka Akira Date: 2010-01-24T14:36:46+09:00 Subject: [ruby-core:27754] Re: [Bug #2636] Incorrect UTF-16 string length 2010/1/24 Vincent Isambart : > Bug #2636: Incorrect UTF-16 string length > http://redmine.ruby-lang.org/issues/show/2636 > str = "\xDC\x0B\xD8\x40".force_encoding(Encoding::UTF_16BE) > str.length #=> 3 > > This string is made by inverting 2 words of a UTF-16 character not in the BMP. > The length should be 2 because it's made of two (unpaired) surrogates and not 3. Fixed. % ./ruby -ve ' s = "\xDC\x0B\xD8\x40".force_encoding(Encoding::UTF_16BE) p s p s.length' ruby 1.9.2dev (2010-01-24 trunk 26392) [i686-linux] "\xDC\x0B\xD8\x40" 2 -- Tanaka Akira