# Firewatir and Accents

**URL:** <https://www.ruby-forum.com/t/firewatir-and-accents/175903>\
**Category:** Ruby\
**Created:** [September 22, 2009, 4:43pm UTC](https://www.ruby-forum.com/t/firewatir-and-accents/175903 "2009-09-22T16:43:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7c8e57/32.png) [@Axel\_E](https://www.ruby-forum.com/u/Axel_E)\
**Post date:** [September 22, 2009, 4:43pm UTC](https://www.ruby-forum.com/t/firewatir-and-accents/175903/1 "2009-09-22T16:43:50Z")

</div>

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 = “[Conjugador de Verbos da Língua Portuguesa](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)  
}
