Re: Iconv and incompatible encodings



I have also a problem with iconv. I'm under linux (configured with utf-8
as usual) and under irb I get:
irb(main):016:0> Iconv.conv("US-ASCII//TRANSLIT","UTF-8",'éèêë')
=> "eeee"

But when I try the same in ruby or mod_ruby I get '????', for example:
$ ruby -e "require 'iconv'; puts
Iconv.conv('US-ASCII//TRANSLIT','UTF-8','éèêë')"
????
I already checked with str.each_byte {|x| puts x} and the strings are
exactly the same. Does anyone have any idea why I get two different
answers from Iconv?

My system:
$ irb --version
irb 0.9.5(05/04/13)
$ ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

I have ENV['LANG']==en_US.UTF-8 in both cases.
--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: iconv transfer code
    ... pt@pt-laptop:~$ irb ... irb:001:0> require 'iconv' ... One of the joys of ruby 1.9 is that the same program run on two ... There are about 200 cases of encoding behaviour described there. ...
    (comp.lang.ruby)
  • Re: Difference in iconv between ruby and irb
    ... in your Ruby code) and I get the below: ... Sad to say but this is a problem that we have spent many hours trying to ... and importing parts of irb. ... That works properly on our system even though Iconv ...
    (comp.lang.ruby)
  • Re: Iconv and incompatible encodings
    ... On Oct 13, 2008, at 12:48 PM, Davi Barbosa wrote: ... as usual) and under irb I get: ... But when I try the same in ruby or mod_ruby I get '????', ... Try adding the -KU switch to Ruby, to put it in UTF-8 mode. ...
    (comp.lang.ruby)
  • Re: UCS-2
    ... Is there any way to decode a UCS-2 string with ruby? ... irb> require 'iconv' ...
    (comp.lang.ruby)
  • Difference in iconv between ruby and irb
    ... puts Iconv.iconv('ASCII//TRANSLIT', 'UTF-8', s) ... What should I import to my script or where is the difference between ruby interpreter and irb that makes it working in the second case? ...
    (comp.lang.ruby)