Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic