From: Calvin Nguyen Date: 2009-08-11T05:56:10+09:00 Subject: Re: ActiveRecord to_json encoding Brian, I really appreciate the quick reply and the insight. Our team was contemplating upgrading to Ruby 1.9 for all the new features but have concerns with any regression. Will you tell me why you reccommend staying on 1.8.6 for production rather than 1.9? Also how do you enter the accented e on "Caf辿" in the console (IRB)? Thanks in advance. Brian Candler wrote: > Calvin Nguyen wrote: >> >> Question: >> Hi, our company is using Ruby 1.8.6 with Rails 2.2.2. Does anyone >> know we can explicitly specify what encoding to use when calling > > Answer: > Yes, almost certainly someone does. But you will be more likely to find > them on a Rails mailing list. This is the mailing list for Ruby, the > programming language. > > If you install ruby 1.9 somewhere, it has some features you can use to > experiment with encodings. For example: > > $ irb19 --simple-prompt >>> str = "Caf辿" > => "Caf辿" >>> str.bytes.map { |x| "%02x" % x } > => ["43", "61", "66", "c3", "a9"] >>> str.encode!("ISO-8859-1") > => "Caf >>> str.bytes.map { |x| "%02x" % x } > => ["43", "61", "66", "e9"] >>> > > But I suggest you keep your 1.8.6 for production use. -- Posted via http://www.ruby-forum.com/.