Paul Battley
8/18/2006 6:44:00 PM
On 18/08/06, Antonio Mat <atd@ruidodebarrio.org> wrote:
> I have spent several hours searching for this and I still don't know how
> it works.
>
> How is `cmd` string encoded? I want it in UTF-8, but I don't know how to
> do it!
> I have tried with $KCODE = 'u' but it doesn't works.
> My Ruby version is 1.8.2
Do you mean the return value? That depends on your platform, locale,
and, possibly, the program itself. If you know the encoding, you can
use Iconv to convert it to UTF-8:
require 'iconv'
s = `some cmd` # returns a string in iso-8859-1, for example
iconv = Iconv.new("utf-8", "iso-8859-1")
iconv.iconv(s) # => string in UTF-8
Perhaps you could post a sample of code to show what you are trying to
do. It's easier to solve a concrete problem than to read minds.
Paul.