I have a Sinatra application (http://analyzethis.espace-technologies.com) that does the following
Because Net::HTTP does not handle encoding correctly. See http://bugs.ruby-lang.org/issues/2567
You can parse response['content-type']
which contains charset instead of parsing whole response.body
.
Then use force_encoding()
to set right encoding.
response.body.force_encoding("UTF-8")
if site is served in UTF-8.