Search code examples
rubyutf-8geokit

Ruby, rvm and geokit gem. Trouble with UTF-8


i use rvm, Ruby 1.9.3 and geokit(1.6.0) gem and have trouble with UTF-8.

i added line export RUBYOPT=-Ku to my ~/.rvm/environments/@default and replaced exec ruby "$@" with exec ruby -Ku "$@" in ~/.rvm/bin/ruby. Then i'm tryed to execute File.rb with two strings:

require 'geokit'
a=Geokit::Geocoders::GoogleGeocoder.geocode 'München'

Error:

ruby-1.9.3-p0@mygemset/gems/geokit-1.6.0/lib/geokit/geocoders.rb:443:in `do_geocode': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)

Why export RUBYOPT=-Ku and exec ruby -Ku "$@" dont work for geocoders.rb and work for File.rb? Can anybody help me?


Solution

  • # encoding: UTF-8
    require 'geokit'
    require 'cgi'
    
    a = Geokit::Geocoders::GoogleGeocoder.geocode(CGI.escape('München'))