Why jcode.rb?

Posted by Shugo Maeda Fri, 16 Sep 2005 14:59:00 GMT

I'm wondering why so many people use jcode.rb on Rails. jcode.rb may break other libraries because it redefines some methods of String. So I recommend you not to use jcode.rb if it is not really necessary.

In many cases, you can use Regexp instead. For example,

require "jcode"

$KCODE = "u"
s.each_char do |ch|
  puts ch
end

This code can be rewritten like this:

s.scan(/./mu) do |ch|
  puts ch
end

I admit that the latter is less readable than the former. M17N features or selector namespace will fix this problem completely in the near future, I hope.

Leave a comment, View comments, View trackbacks

Your Comments.

Leave your own response

Other posts about this post.

This post has been discussed on the following web sites / blogs. If you wish to trackback to this post please use the following trackback address: http://blog.shugo.net/articles/trackback/10

Spread the word.

Shugo's Blog supports RSS (Real Simple Syndication), and Trackbacks from other blogs.

RSS feed for this post Trackback URI

Your Reply

Comment Form.

Fields denoted with a "*" are required.

You may also like to leave your email or website.