This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Character encoding with German chars & euro other than UTF-8 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Character encoding with German chars & euro other than UTF-8" Watch "Character encoding with German chars & euro other than UTF-8" New topic
Author

Character encoding with German chars & euro other than UTF-8

Ted Bell
Ranch Hand

Joined: Jan 21, 2002
Posts: 52
Hi all,

I have a servlet to turn out some values in a CSV file. Everything works fine except that in some cases the file can have special German characters and the Euro symbol. When I download the file and open in Notepad, everything looks fine (using UTF-8 encoding). When opening in Excel however, it does not. I have read in other forums that Excel does not like UTF-8, but I can't find a way to encode it that Excel does like.

The content being output is represented in the code as a String (parsed from a Velocity template). I saw something somewhere that Strings and byte arrays behave differently.

There has to be a way to handle this. Is there some conversion on the content I should do prior to outputting?

Any help appreciated.
Ted Bell
Ranch Hand

Joined: Jan 21, 2002
Posts: 52
Update:

I download the file from two machines with two different results. On my Windows desktop, the file looks fine in notepad and Excel. When I move the servlet to a Solaris box, it renders fine in notepad, but the euro symbol is not displayed correctly in excel. The difference (or the only difference I have found so far) seems to be related to the "file.encoding" system property. On Windows it is "cp1252" and on Solaris it's coming as "ISO8859-15", which I think was changed from the default (whatever it was) by a sysadmin.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Character encoding with German chars & euro other than UTF-8
 
Similar Threads
Question on Characetr Encoding to UTF-8
Different behavior between getWriter and getOutputStream
JSP Character Encoding
file name issue
XML -> SAX -> MYSQL conversion losing character encoding...