Bug#676114: Ruby help needed (Was: Bug#676114: wordnet: FTBFS: debian/wn-for-goldendict.rb:465: invalid multibyte char (US-ASCII))

Per Andersson avtobiff at gmail.com
Tue Jun 5 22:54:38 UTC 2012


tag 676114 + patch
kthxbye

Hi!

On Tue, Jun 5, 2012 at 6:53 PM, Andreas Tille <andreas at an3as.eu> wrote:
> Hi Sam,
>
> On Tue, Jun 05, 2012 at 11:26:42AM -0400, Sam Ruby wrote:
>> On 06/05/2012 10:08 AM, Andreas Tille wrote:
>> >>>debian/wn-for-goldendict.rb:465: invalid multibyte char (US-ASCII)
>> >>>debian/wn-for-goldendict.rb:465: invalid multibyte char (US-ASCII)
>> >>>debian/wn-for-goldendict.rb:465: syntax error, unexpected $end, expecting ')'
>> >>>     print_array(@words, 'Syn', "[c blue]•[/c]")
>>
>> Probable fix: add the following at the top of the file (as first
>> line if there is no #! line, or immediately after that):
>>
>>   # encoding: utf-8
>
> OK, sounds quite reasonable and leads to a next (different) error:
>
>                ruby debian/wn-for-goldendict.rb > goldendict-wordnet.dsl; \
>        fi
> WARNING: sentidx.vrb format error: ["pet%2:35:00::"]
> debian/wn-for-goldendict.rb:300:in `initialize': undefined method `times' for "\x01":String (NoMethodError)
>        from debian/wn-for-goldendict.rb:158:in `new'
>        from debian/wn-for-goldendict.rb:158:in `get_data'
>        from debian/wn-for-goldendict.rb:648:in `block (2 levels) in <main>'
>        from debian/wn-for-goldendict.rb:647:in `each'
>        from debian/wn-for-goldendict.rb:647:in `block in <main>'
>        from debian/wn-for-goldendict.rb:644:in `foreach'
>        from debian/wn-for-goldendict.rb:644:in `<main>'
> make: *** [goldendict-wordnet.dsl] Error 1
>
> Any further hint?

It seems the problem is that Ruby 1.8 and 1.9 handles byte conversions
differently.

With Ruby 1.8, converts to octal and then to integer (by array indexing!)

    irb(main):017:0> ["10"].pack('H2')
    => "\020"
    irb(main):018:0> ["10"].pack('H2')[0]
    => 16


With Ruby 1.9, converts to byte and then no more conversion (array
indexing is just indexing)

    irb(main):061:0> ["10"].pack('H2')
    => "\x10"
    irb(main):062:0> ["10"].pack('H2')[0]
    => "\x10"


There are several ways to perform the conversion with Ruby 1.9

    irb(main):067:0> ["10"].pack('H2')
    => "\x10"
    irb(main):068:0> ["10"].pack('H2').unpack('C')[0]
    => 16
    irb(main):069:0> ["10"].pack('H2').bytes.to_a[0]
    => 16


See http://stackoverflow.com/a/3772446 and links for more information.


Please see the attached patch and try if it works.


Best,
Per

> Thanks for your quick reply anyway
>
>     Andreas.
>
> --
> http://fam-tille.de
>
>
> --
> To UNSUBSCRIBE, email to debian-mentors-REQUEST at lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster at lists.debian.org
> Archive: http://lists.debian.org/20120605165338.GA24393@an3as.eu
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: convert-bytes-to-integer-with-ruby1.9.patch
Type: application/octet-stream
Size: 356 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debian-science-maintainers/attachments/20120606/4cddb5de/attachment.obj>


More information about the debian-science-maintainers mailing list