0

In a Java portlet I'm offering files to download through the serveResource(...) method.

I'm calling

response.getPortletOutputStream().write(byteArray);

This byte array contains some special characters in German, for example Ä, Ü or ö. The file format of the resulting file is csv.

When I'm opening the file in a text editor, the special characters are displayed correctly.

However when I open them in Microsoft Excel, they're displayed as ü or ß.

Do you have any ideas of what could be the cause of this problem?

Notepad++ displays the file as

ANSI as UTF-8

  • 1
    Do you write an UTF-8 BOM (byte order mark) at the start of your CSV? If not, Excel might just not know it's an UTF-8 file. Other editors might scan the text and try to determine the encoding from the content, if the BOM is missing. – Thomas Nov 28 '11 at 14:10

1 Answers1

1

This might help you: Microsoft Excel mangles Diacritics in .csv files?

Basically, you'd need to add a byte order mark (BOM) to your CSV file.

Community
  • 1
  • 1
Thomas
  • 87,414
  • 12
  • 119
  • 157
  • I'm writing the BOM with `outputStream.write(239); outputStream.write(187); outputStream.write(191);` now. See also http://mindprod.com/jgloss/bom.html –  Nov 28 '11 at 14:55