Strange error in jcode.rb when converting range to array

In my rails app I’ve line with the following code:

(“a”…“z”).to_a

Simple enough and it’s been working for a while. Last night this line
started throwing the following error:

undefined method []' for nil:NilClass /usr/local/lib/ruby/1.8/jcode.rb:83:insucc!’
/usr/local/lib/ruby/1.8/jcode.rb:94

I looked up jcode.rb and the comments for this file say that it’s “#
jcode.rb - ruby code to handle japanese (EUC/SJIS) string”

This is the part of jcode.rb that throws the error (line 83)

78 def succ!
79 reg = end_regexp
80 if self =~ reg
81 succ_table = SUCC[$KCODE[0,1].downcase]
83 begin
84 self[-1] += succ_table[self[-1]]
85 self[-2] += 1 if self[-1] == 0
86 end while self !~ reg
87 self
88 else
89 original_succ!
90 end
91 end

Debugging is difficult because if I restart the app, the problem goes
away…for a while. Has anyone else encountered this error before?

It’s obviously being caused by something I’ve added to my app
recently. I just can’t figure out what.

ruby -v
ruby 1.8.4 (2005-12-24) [i686-darwin8.5.2]

Thanks

Hammed

Hammed M. wrote:

In my rails app I’ve line with the following code:

(“a”…“z”).to_a

When I try this with jcode loaded it immediately breaks. It looks like
other people have noticed it too and there is a fix:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/28980

I guess you will have to work around it for now.

Hi,

In message “Re: Strange error in jcode.rb when converting range to
array”
on Fri, 29 Sep 2006 02:20:18 +0900, “Manfred Stienstra”
[email protected] writes:

|Hammed M. wrote:
|> In my rails app I’ve line with the following code:
|>
|> (“a”…“z”).to_a
|
|When I try this with jcode loaded it immediately breaks. It looks like
|other people have noticed it too and there is a fix:
|
|http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/28980

No, it’s about 1.9 and the OP was using 1.8.4. I will examine it
later.

						matz.

Hi,

In message “Re: Strange error in jcode.rb when converting range to
array”
on Fri, 29 Sep 2006 09:49:03 +0900, “Hammed M.”
[email protected] writes:

|The perplexing part for me was why jcode.rb was even being used by my
|code. A bit embarrasing to admit on a mailing list but somehow the
|line include “jcode” got included in one of my less used rails
|controller. I don’t have any need for Japanese characters in my app so
|I can’t imagine adding that line myself. I’m suspecting Textmate has a
|hotkey for inserting that line that I pressed inadvertantly.

I’ve heard Rails uses jcode to handle UTF-8.

I was telling the article in the ruby-dev list has nothing related to
your problem. It is caused by a bug in jcode.rb, and is just fixed in
the CVS.

						matz.

Hi Matz,

The perplexing part for me was why jcode.rb was even being used by my
code. A bit embarrasing to admit on a mailing list but somehow the
line include “jcode” got included in one of my less used rails
controller. I don’t have any need for Japanese characters in my app so
I can’t imagine adding that line myself. I’m suspecting Textmate has a
hotkey for inserting that line that I pressed inadvertantly.

Hammed

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs