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.
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?
I wouldn't expect it to log utf-8 properly without configuring it.