HTTPResponse Character Encoding

View: New views
4 Messages — Rating Filter:   Alert me  

HTTPResponse Character Encoding

by Don Zuiker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

How do I change the character encoding that the getText() method in
HTTPResponse uses?

Thanks,
Don

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use

Re: HTTPResponse Character Encoding

by Philip Aston-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don Zuiker wrote:
> Hi,
>
> How do I change the character encoding that the getText() method in
> HTTPResponse uses
>  

Its derived from the content type declared by the response. Check out
http://grinder.svn.sourceforge.net/viewvc/grinder/tags/release_3_2/source/src/HTTPClient/HTTPResponse.java?revision=3977&view=markup#l_548

If you want to use something different, best to use getData() to get the
raw bytes and wrap them in a String with the appropriate encoding.

- Phil

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use

Parent Message unknown Re: HTTPResponse Character Encoding

by Don Zuiker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Phil,

I have tried that and I get a general "SyntaxError: ('invalid syntax',..."  message for the line that wraps what's returned from getData().

Here's what I have:

String translatedResult = new String(result.getData(), "UTF-8")

I confirmed the content type as "text/html; CHARSET=UTF-8" from the system under test.

It looks like The Grinder should find the CHARSET automatically but when I use result.getText() it just returns what looks like corrupted data.  


Thanks,
Don




Message: 4
Date: Mon, 02 Nov 2009 17:22:33 +0000
From: Philip Aston philip.aston@...
Subject: Re: [Grinder-use] HTTPResponse Character Encoding
To: grinder-use grinder-use@...
Message-ID: 4AEF1559.4060406@...
Content-Type: text/plain; charset=UTF-8

Don Zuiker wrote:
> Hi,
>
> How do I change the character encoding that the getText() method in 
> HTTPResponse uses
>   
  

Its derived from the content type declared by the response. Check out
http://grinder.svn.sourceforge.net/viewvc/grinder/tags/release_3_2/source/src/HTTPClient/HTTPResponse.java?revision=3977&view=markup#l_548

If you want to use something different, best to use getData() to get the
raw bytes and wrap them in a String with the appropriate encoding.

- Phil

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use

Re: HTTPResponse Character Encoding

by Philip Aston-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don Zuiker wrote:
> Hi Phil,
>
> I have tried that and I get a general "SyntaxError: ('invalid syntax',..."  message for the line that wraps what's returned from getData().
>
> Here's what I have:
>
> String translatedResult = new String(result.getData(), "UTF-8")
>  
That's Java. You need to write Jython :-)

Try:

from java.lang import String
#...
translatedResponse = String(result.getData(), "UTF-8")

> I confirmed the content type as "text/html; CHARSET=UTF-8" from the system under test.
>
> It looks like The Grinder should find the CHARSET automatically but when I use result.getText() it just returns what looks like corrupted data.  
>
>  

Perhaps getText() is returning the right thing, but the way you write it
out to the display can't cope with utf-8? Try writing to a file, e.g. as
per http://grinder.sourceforge.net/g3/script-gallery.html#http, then
opening it in a text editor.

- Phil


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use