Google Ajax Search API - UTF-8 encoded response

Hello All,

I am writing a facebook application in ruby on rails, which requires
google search in one page.
I’ve implemented this using a simple RESTful interface as follows:

url = URI.parse( “http://ajax.googleapis.com/ajax/services/search/
local?v=1.0&q=”+params[:keyword] )
req = Net::HTTP::Get.new(url.path+"?"+url.query)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req) }

The response has a Content-Type of text/javascript; charset=utf-8. and
in JSON format

So, I’m decoding the response into a hash as
hash = ActiveSupport::JSON.decode(res.body)

But, the data still contains some special characters starting with \u
(utf-8 characters)

How to decode them into html text in ruby?

Thanks in Advance,
Prasad

Hello Everybody,

Is there anything like Unicode.deocode(str) (I found it somewhere when
I googled, but not working )??
I have installed unicode using gem install unicode, but couldn’t get
how to use it.

Please please help me out solving this problem.

Thanks,
Prasad

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