Ruby 1.9.1, HTTP and Encodings

H

Hannes Wyss

Hi All

I'm running into a "Encoding::CompatibilityError: incompatible
character encodings: UTF-8 and ASCII-8BIT" when using Selenium to run
my functional tests, specifically when calling assert_equal to compare
the expected value 'Best=E4tigung' with the value retrieved by Selenium
from the web-page. The expected value is correctly encoded as UTF-8,
the value retrieved by Selenium is labeled ASCII-8BIT. Otherwise they
are identical. (see also http://trac.ywesee.com/ticket/1#comment:13)

I've tracked the issue down to http. I believe it would be very
helpful if HTTP could force the encoding of the received body to the
value provided in the Content-Type-header. Or, failing that, to the
default internal encoding.

Have others run into the same issue? How did you solve it?
Thanks in advance,

all the best,
Hannes



hwyss@work ~ $ uname -a
Linux work 2.6.27.4 #1 SMP PREEMPT Wed Nov 5 17:07:20 CET 2008 x86_64
Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
hwyss@work ~ $ ruby19 --version
ruby 1.9.1p129 (2009-05-12 revision 23412) [x86_64-linux]
hwyss@work ~ $ irb19 --version
irb 0.9.5(05/04/13)
hwyss@work ~ $ irb19
irb(main):001:0> Encoding.default_internal =3D 'UTF-8'
=3D> "UTF-8"
irb(main):002:0> require 'net/http'
=3D> true
irb(main):003:0> Net::HTTP.start('ch.oddb.org') do |http|
http.get('/').body.encoding end
=3D> #<Encoding:ASCII-8BIT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top