Irb differs from script

hi,

i’m trying to remove special characters from a string using iconv and it
works nicely in irb. When i run the same code in a script… it doesn’t
work though :frowning:

Any clues what could be the difference?

irb:
irb(main):001:0> require ‘iconv’
=> true
irb(main):002:0> s = “genève”
=> “gen\303\250ve”
irb(main):003:0> puts s.gsub(/./) {|s| s[0].to_s + ’ '}
103 101 110 195 168 118 101
=> nil
irb(main):004:0> s = “genève”
=> “gen\303\250ve”
irb(main):005:0> b = Iconv.conv(‘ascii//translit’,‘UTF-8’, s)
=> “geneve”
irb(main):006:0> puts b
geneve
=> nil

script:
require ‘iconv’

s = “genève”
puts s.gsub(/./) {|s| s[0].to_s + ’ '}
s = “genève”
b = Iconv.conv(‘ascii//translit’,‘UTF-8’, s)
puts b

output:
103 101 110 195 168 118 101
gen?ve

any clues anyone ?

tnx,

Martijn