Details
Description
Data coming out of my UTF-8 format Postgres database appears correctly in displaytag tables on webpages, but when I request an export in Excel or text format, all non ASCII characters are garbled. I am using the Mac OS X Platform.
After some exploration, I determined that this is due to the file encoding being set to Windows Latin-1. Excel documents which were created on Windows and that I open on my Mac do not have garbled non-ASCII text, so I suspect that all that is missing in the exported file is some way to indicate to Excel what encoding has been used. Some of my recent web searches suggest that at least the more recent versions of Office store characters in little-endian UCS2 encoding.
For text files, it seems to me that UTF-8 would be the the most platform and language agnostic encoding to use.
After some exploration, I determined that this is due to the file encoding being set to Windows Latin-1. Excel documents which were created on Windows and that I open on my Mac do not have garbled non-ASCII text, so I suspect that all that is missing in the exported file is some way to indicate to Excel what encoding has been used. Some of my recent web searches suggest that at least the more recent versions of Office store characters in little-endian UCS2 encoding.
For text files, it seems to me that UTF-8 would be the the most platform and language agnostic encoding to use.
If you set utf-8 encoding in page with
<jsp:directive.page contentType="text/html; charset=UTF8" />
or
response.setContentType("text/html; charset=utf-8");
displaytag correctly preserve encoding and csv/excel output is written using utf8.
Are you sure you are setting the output encoding correctly? Are you facing this problem with the displaytag filter enabled or not? Which version of displaytag are you using?
Please reopen the bug if you are trying with the latest snapshot and you are sure everything has been done correctly (i.e. charset is set to utf8 when not exporting).
You can look in displaytag test code for
DISPL-107.jsp and Displ107.java for an example of a working utf8 export.