Reading a UTF-8 String from an XMl file in Java in a GWT environment

I am reading an XML file using Scanner scanner = new Scanner(inputStream, "UTF-8"); and then going line by line using scanner.nextLine().

I have some UTF-8 type text in the XML file that I read and it works perfectly when I run my app locally through the Jetty server in my Eclipse Helios IDE.

However when the app is built and deployed on a tomcat server that we use as out dev server, the UTF-8 characters appear as '?' everywhere. When I put some logs in place I found that the characters were being read that way in spite of me mentioning UTF-8 when I initialize the scanner.

I am unable to understand why it would work locally for me but not when I deploy it on tomcat.

I am sure so many might have come across this before.

Answers


Are you sure you have tomcat configured to display utf-8?

Have you configured the page displaying it? There is a good how to here How to get UTF-8 working in Java webapps?

Also, have you set the default file encoding to utf-8 in catalina.sh?

-Dfile.encoding=UTF-8"

http://www.redleopard.com/2008/12/utf-8-on-tomcat/

I wouldn't expect it to log utf-8 properly without configuring it.


Need Your Help

Assemble Error for AVX2

c++ gcc assembly avx2

I've tried to compile a AVX2 program with gcc(g++). But it didn't work right.

basic table padding with html & dreamweaver

dreamweaver cellpadding

I haven't used DW for a while, excuse my beginners question.