# Ruby 1.9.1, HTTP and Encodings

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-1-http-and-encodings/170940>\
**Category:** Ruby\
**Created:** [June 24, 2009, 9:58am UTC](https://www.ruby-forum.com/t/ruby-1-9-1-http-and-encodings/170940 "2009-06-24T09:58:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spreadsheet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5fc32e/32.png) [@spreadsheet](https://www.ruby-forum.com/u/spreadsheet)\
**Post date:** [June 24, 2009, 9:58am UTC](https://www.ruby-forum.com/t/ruby-1-9-1-http-and-encodings/170940/1 "2009-06-24T09:58:59Z")

</div>

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ätigung’ 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](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™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 = ‘UTF-8’  
=\> “UTF-8”  
irb(main):002:0\> require ‘net/http’  
=\> true  
irb(main):003:0\> Net::HTTP.start(‘[ch.oddb.org](http://ch.oddb.org)’) do |http|  
http.get(‘/’).body.encoding end  
=\> #Encoding:ASCII-8BIT
