[MacRuby] #1124: string.ord returns 0xFFFF for all characters 0x80 or greater in binary string
#1124: string.ord returns 0xFFFF for all characters 0x80 or greater in binary string ------------------------------------------+--------------------------------- Reporter: justin@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: MacRuby 0.9 Component: MacRuby | Keywords: ------------------------------------------+--------------------------------- This problem was introduced with changeset r5054. Here's some test code: {{{ ary = [] "\x00\x01\x7F\x80".each_char { |c| ary << (c.ord & 0xff) } if ary == [0,1,127,128] puts "Looks good" else puts "Expected [0,1,127,128], got [#{ary.join(',')}]" end }}} When run on MacRuby r5053: {{{ Looks good }}} When run on MacRuby r5054 through r5187: {{{ Expected [0,1,127,128], got [0,1,127,255] }}} When run on CRuby 1.9.2: {{{ Looks good }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1124> MacRuby <http://macruby.org/>
#1124: string.ord returns 0xFFFF for all characters 0x80 or greater in binary string ------------------------------------------+--------------------------------- Reporter: justin@… | Owner: vincent.isambart@… Type: defect | Status: new Priority: critical | Milestone: MacRuby 0.9 Component: MacRuby | Keywords: ------------------------------------------+--------------------------------- Changes (by vincent.isambart@…): * owner: lsansonetti@… => vincent.isambart@… Comment: In fact both results are incorrect. Running it in 1.9 (adding {{{#coding: utf-8}}} at the start line of the file) raises an "invalid byte sequence in UTF-8 (ArgumentError)". I don't have MacRuby handy, but looking at the source code there are a few differences with the behavior of 1.9: * {{{String#each_char}}} and {{{String#ord}}} do not throw an exception when the encoding is invalid * {{{String#ord}}} in ASCII-8BIT returns 0xFFFF for non ASCII-characters (it should simply return the byte value) Note that to iterate other the bytes of a string, you should use {{{String#each_byte}}} instead of {{{String#each_char}}}. -- Ticket URL: <http://www.macruby.org/trac/ticket/1124#comment:1> MacRuby <http://macruby.org/>
#1124: string.ord returns 0xFFFF for all characters 0x80 or greater in binary string ------------------------------------------+--------------------------------- Reporter: justin@… | Owner: vincent.isambart@… Type: defect | Status: closed Priority: critical | Milestone: MacRuby 0.9 Component: MacRuby | Resolution: fixed Keywords: | ------------------------------------------+--------------------------------- Changes (by vincent.isambart@…): * status: new => closed * resolution: => fixed Comment: Should be fixed in r5188. -- Ticket URL: <http://www.macruby.org/trac/ticket/1124#comment:2> MacRuby <http://macruby.org/>
#1124: string.ord returns 0xFFFF for all characters 0x80 or greater in binary string ------------------------------------------+--------------------------------- Reporter: justin@… | Owner: vincent.isambart@… Type: defect | Status: closed Priority: critical | Milestone: MacRuby 0.9 Component: MacRuby | Resolution: fixed Keywords: | ------------------------------------------+--------------------------------- Comment(by vincent.isambart@…): Sorry I made a mistake in r5188, should be OK in r5189. -- Ticket URL: <http://www.macruby.org/trac/ticket/1124#comment:3> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby