From: Brian Candler Date: 2010-09-28T02:59:45+09:00 Subject: Re: Encoding problems .. ruby 1.9.2 Bhay Zone wrote: > I invoke query-pr from my ruby program as follows (note the opening and > closing (``) characters. > > result=`query-pr --expr 'Status="closed"'` > # parse the result and take appropriate action. That's backticks. Follow that line with: result.force_encoding("ASCII-8BIT") when running with ruby 1.9, before you start doing your substitutions. > I am not very sure, but my guess is that the GNATS client uses TCP > sockets to interface with the GNATS DB. Maybe, but that's irrelevant here. Ruby is reading the output of query-pr, as a string, and has decided to give it some arbitrary guessed encoding. > Right now I have "# coding: utf-8" as the first line in the ruby file. I > found that while trying to figure out this problem and hoped it would > make magic ... but well ... :-( > > I'll also try out the "# coding: binary" to see if that works for my > case. It won't. It will only affect the coding of quoted string literals within your code. -- Posted via http://www.ruby-forum.com/.