Firewatir and Accents

Dear all,

I’d like to use firewatir to automate a website (ruby 1.9.1p243
on ubuntu jaunty, Firefox 3.0.14, latest firewatir).
The script below is supposed to conjugate some Portuguese verbs.
The code below works nicely as long as there are
no accents in the infinitives of the verbs,
so “fazer” is ok.
But there just seems to be no way to make this
script conjugate a verb with an accent in it, like
“abraçar” (with a c-cedilla).

I tried various combinations of iconv, cgi.escape,…
What’s the best way to do this ?

Thank you very much!

Best regards,

Axel


require ‘rubygems’
require “firewatir”
require “iconv”
require “cgi”

$test_site = “http://linguistica.insite.com.br/cgi-bin/conjugue
$browser = Watir::Browser.new

class PortugueseVerb
attr_accessor :pattern,:tempos,:formas
def initialize(infinitive)
ic_ignore = Iconv.new(‘iso-8859-1’, ‘UTF-8’)
$browser.goto $test_site
verbo=infinitive
$browser.text_field(:name, “verbo”).set verbo
$browser.button(:type, “submit”).click
f=File.new(“port_verbs/verbo_#{infinitive}.txt”,“w”)
f.puts ic_ignore.iconv($browser.text)
f.close
end
end

ic_ignore2 = Iconv.new(‘iso-8859-1’, ‘UTF-8’)

IO.readlines(“port_verbs.txt”).each{|verb|
puts verbo=ic_ignore2.iconv(verb)
PortugueseVerb.new(verbo.chomp)
}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs