#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/>