File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Charset and special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Charset and special characters" Watch "Charset and special characters" New topic
Author

Charset and special characters

Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

I really need some help if anyone can give it to me.

Basically whenever I try to read any special characters from my web application they come up as question marks ???.

I have the application running locally on a tomcat installation and it works fine, however when I move it to the live environment (which is managed hosting) I get this problem, I am setting the content type to UTF-8. Code looks like this:



I decided to check what the default charset was by using:

On the one that works the charset was UTF-8 and on the other it was US-ASCII.
Does anyone know if that is the problem??

Any suggestions at all?
I am at a loss!

Sean


I love this place!
binayakumar patel
Greenhorn

Joined: Jun 26, 2009
Posts: 27
Hi Sean,

Can you please give the screen shot , as well as the special character with which you have the problem.
Because when ever we try to display character like '>' we use "& gt"
So I think you need to convert your special code in this form to read this.

Regards
Binaya
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

♥ÐệªŦĥ›ßỹ‹§∑

Really it is any unusual character like those and of course loads and loads more. Typical characters £^$%&*(<> etc all work fine though.

I understand that you mean use the HTML entity name? This also does not work, as by the time I convert it in the servlet it is already '???'s

Any other suggestions?

It really is getting annoying!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

First of all get rid of this line of code:

It can't be doing anything useful and it's possible for it to be harmful. And you might want to read this article:

Character Conversions from Browser to Database
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
Note that seeing ??? on the screen does NOT necessarily mean that the app is trying to show the ASCII question mark. It may mean that your system simply doesnt have a font to show the special character.

Try displaying the string character by character values in hex form.

Bill
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

thank you guys for your suggestions. I can't try them just now, but I will and I will let you know the outcome.

Try displaying the string character by character values in hex form.


Also William what do you mean by this? Sorry if it sounds like a stupid question.

Sean
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
I am thinking he is suggesting you display the hex value of each character that makes up he string.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

A quick update, I was about to try some of your suggestions. But before I did I thought I'd test it again.
For some reason my when using:

My server is now outputting UTF-8 instead of US-ASCII which it was doing the other day and now everything works fine (so it seems that this was the problem).
My worry is that this is going to change again on it's own (or without me doing anything since this is hosted in a managed environment).

Anyway it works for now, thanks for your suggestions.

Sean
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Charset and special characters