Problemas com encoding

48 views
Skip to first unread message

Reginaldo Sousa

unread,
Feb 21, 2011, 10:33:17 AM2/21/11
to restfulie
Caros,

Estou fazendo uma requisição GET a um servidor que responde com um
JSON com uma lista de produtos.
Se eu abrir o endereço direto no navegador, o JSON me mostra as
palavras corretamente, com os acentos.
Mas se eu fizer a requisição utilizando o Restfulie(Ruby), os nomes
dos produtos que tem acento ficam errados.
Tem como eu configurar qual charset ele deve utilizar ou alguma outra
solução?

Abraços,

Guilherme Silveira

unread,
Feb 23, 2011, 7:24:05 PM2/23/11
to rest...@googlegroups.com, Reginaldo Sousa
Hi Reginaldo,

The list if in english so I will reply in english... if you need, join
the #restfulie channel, we spoke both in english and portuguese there.
The problem is related to our usage of Net::HTTP. Can you check
exactly which headers your browser is sending? Try using the POSTER
plugin for firefox (or anything similar). Let me know then and we can
add the support as in:

Restfulie.at(uri).charset('')....

You can also try the following meanwhile:

Restfulie.at(uri).accepts('application/json; charset=add_your_charset_here').get


Regards


Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

2011/2/21 Reginaldo Sousa <regina...@gmail.com>:

Reginaldo Sousa

unread,
Mar 2, 2011, 1:56:46 PM3/2/11
to restfulie
Hi Guilherme,

I tried using the method. charset (), but it returned me an error
unknown method.
Trying to pass the charset in Accept I got the same result as if
nothing was going.

I'll explain the problem as a whole:
I have a Java application (with vraptor) which returns JSON data I
want to use in other environments.
In my Rails application I have a controller that serves as a proxy for
ajax requests, via jQuery.

But the accentuation never come properly.


Follows the HTTP header sent by the browser:
Host localhost:3000
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:
1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept application/json, text/javascript, */*; q=0.01
Accept-Language pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
x-requested-with XMLHttpRequest
Referer http://localhost:3000/extratos/6627872
Cookie SQLiteManager_currentTheme=green;
_IspAdmin3_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlY2QzNDc4NDQ5ZDYzOGY3MjdmMmY0NWY4Zjc3MjYwZjZJIhBfY3NyZl90b2tlbgY7AEZJIjF4V0hwSXJ6am00RTZZVDlXRUxNTzdiUnMwRFFsbmFDbjlGMGZwTCtlMnQwPQY7AEY
%3D--c9b1cce49eb9121b5a40b1d2b6d9462814ae3fd0;
JSESSIONID=FF14AD4742FF1326B6E40DE07ED75C82

On Feb 23, 9:24 pm, Guilherme Silveira
<guilherme.silve...@caelum.com.br> wrote:
> Hi Reginaldo,
>
> The list if in english so I will reply in english... if you need, join
> the #restfulie channel, we spoke both in english and portuguese there.
> The problem is related to our usage of Net::HTTP. Can you check
> exactly which headers your browser is sending? Try using the POSTER
> plugin for firefox (or anything similar). Let me know then and we can
> add the support as in:
>
> Restfulie.at(uri).charset('')....
>
> You can also try the following meanwhile:
>
> Restfulie.at(uri).accepts('application/json; charset=add_your_charset_here').get
>
> Regards
>
> Guilherme Silveira
> Caelum | Ensino e Inovaçãohttp://www.caelum.com.br/
>
> 2011/2/21 Reginaldo Sousa <reginaldo....@gmail.com>:

Guilherme Silveira

unread,
Mar 2, 2011, 6:13:34 PM3/2/11
to rest...@googlegroups.com

Hi Reginaldo.

Can you make a curl request on the terminal and check that vrpator.is answering correctly? And the same for the rails proxy? Can you post both responses here? If you can also extract the java and ruby controllers that fail your test i can simulate and fix it here

Regards

<guilherme.silve...@caelum.com.br> wrote:
> Hi Reginaldo,
>
> The list if in english so I will reply...

> Caelum | Ensino e Inovaçãohttp://www.caelum.com.br/
>
> 2011/2/21 Reginaldo Sousa <reginaldo....@gmail.com>:

>
> > Caros,
>
> > Estou fazendo uma requisição GET a um servidor que responde com um

> > JSON com u...

Reply all
Reply to author
Forward
0 new messages