[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-user
Subject:    Re: [Htmlunit-user] encoding problem
From:       farmazone <farmazone () gmail ! com>
Date:       2010-10-27 11:35:06
Message-ID: 4B079515-F12F-407C-9721-6574BC0FADDB () gmail ! com
[Download RAW message or body]

Yes Marc you are right!

I just added res.setCharacterEncoding("UTF-8"); at the very beggining of doFilter \
method and now all chars are properly displayed. 

Thank you and thanks to Ahmed for help :)


On 2010-10-27, at 12:57, Marc Guillemot wrote:

> Hi,
> 
> page.asXml() returns a String and therefore is not ISO8859-1 encoded (or 
> with some other encoding).
> 
> The problem here is probably that you don't explicitly configure any 
> encoding information on your ServletResponse and therefore it is falling 
> back to ISO8859-1.
> 
> Cheers,
> Marc.
> -- 
> HtmlUnit support & consulting from the source
> Blog: http://mguillem.wordpress.com
> 
> 
> On 10/27/2010 08:45 AM, farmazone wrote:
> > 
> > I have created class that implements javax.servlet.Filter and put it
> > into doFilter method:
> > 
> > @Override
> > public void doFilter(ServletRequest req, ServletResponse res,
> > FilterChain chain) throws IOException, ServletException {
> > 
> > HttpServletRequest request = (HttpServletRequest) req;
> > 
> > String queryString = request.getQueryString();
> > 
> > if (queryString != null && queryString.contains("_escaped_fragment_")) {
> > 
> > final WebClient webClient = new WebClient();
> > 
> > HtmlPage page = webClient
> > .getPage("http://127.0.0.1:8888/Biba.jsp#!h1");
> > 
> > webClient.waitForBackgroundJavaScript(5000);
> > 
> > PrintWriter out = res.getWriter();
> > 
> > String prs = page.asXml();
> > 
> > out.println(prs);
> > 
> > // webClient.closeAllWindows();
> > 
> > } else {
> > 
> > try {
> > 
> > chain.doFilter(req, res);
> > } catch (ServletException e) {
> > System.err.println("Servlet exception caught: " + e);
> > e.printStackTrace();
> > }
> > 
> > }
> > 
> > }
> > 
> > 
> > set it up in web.xml.
> > 
> > on main app class that implements EntryPoint I have only 4 buttons and
> > one of them has a label with special chars . Html page is uft-8 encoded
> > and has doctype: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
> > Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> > 
> > 
> > 
> > On 2010-10-26, at 20:26, Ahmed Ashour wrote:
> > 
> > > Hi,
> > > 
> > > Please provide minimal GWT app that shows this behavior.
> > > 
> > > Ahmed
> > > ----
> > > Blog: http://asashour.blogspot.com
> > > ------------------------------------------------------------------------
> > > *From:* farmazone <farmazone@gmail.com <mailto:farmazone@gmail.com>>
> > > *To:* htmlunit-user@lists.sourceforge.net
> > > <mailto:htmlunit-user@lists.sourceforge.net>
> > > *Sent:* Tue, October 26, 2010 7:07:39 PM
> > > *Subject:* [Htmlunit-user] encoding problem
> > > 
> > > Hello,
> > > 
> > > I saw lots of posts about similiar issue but none of them provided me
> > > a solution.
> > > 
> > > On my AJAX page (made with GWT 2.0) I have some text with non-latin
> > > characters like "ążźć".
> > > Website is utf-8 encoded but page.asXml() prints it as iso-8859-1 and
> > > all my special chars are question marks..
> > > 
> > > Is there a way to change this behaviour? change default HtmlUnit encoding?
> > > 
> > > I need HtmlUnit to make my website crawlable by Google.
> > > 
> > > Thanks in advance,
> > > Michal
> > > 
> 
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Htmlunit-user mailing list
> Htmlunit-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/htmlunit-user


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic