Seam attachments of Japanese text files created on Windows machines are
received as corrupted files
---------------------------------------------------------------------------------------------------
Key: JBSEAM-4735
URL: https://jira.jboss.org/browse/JBSEAM-4735
Project: Seam
Issue Type: Bug
Components: Mail
Affects Versions: 2.2.0.GA
Environment: Tested separately on two systems: System 1: HP Touchsmart
tx2 AMD Turion X2 64-bit, 8GB memory, Ubuntu 10.04 LTS 64-bit, JBoss AS
5.1.0.GA, Eclipse Galileo and Eclipse Helios, Seam 2.2.0.GA. System 2: Fujitsu
FMV-S8235 Intel Core Duo, 4GB memory, Windows Server 2003 32-bit, Eclipse
Galileo, JBoss AS 5.1.0.GA, Seam 2.2.0.GA.
Reporter: Jeff Wexler
Assignee: Pete Muir
If a user attaches a file that they created on a Windows native Japanese
operating system, using any of the file save encoding formats for notepad
(i.e., a normal Japanese text file in Windows) with Japanese text inside, then
that file will be received with the Japanese text inside the text file garbled
up (i.e., garbage instead of Japanese characters). However, if that same file
is uploaded to a database and then downloaded to a windows native Japanese
operating system machine, the Japanese text inside the text file is preserved.
I needed to perform the following conversion to make a Japanese file name work
for the upload/download. I list it here in case it sheds any light on
addressing the bug (above).
For the Japanese name of the file:
byte[] nameSjis;
String nameISO = null;
try {
nameSjis = attachment.getNameStr().getBytes("Shift_JIS");
nameISO = new String(nameSjis, "ISO8859_1");
}
response.addHeader("Content-Disposition", "attachment; filename=" + nameISO);
try {
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(attachment.getDataBytAry());
outputStream.flush();
outputStream.close();
facesContext.responseComplete();
}
Note that the following do not help with the bug (i.e., seam attachment issue):
dataBytAry.toString().getBytes("MS932");
dataBytAry.toString().getBytes("UTF8");
dataBytAry.toString().getBytes("Shift_JIS");
new String(dataBytAry, "utf-8");
Note also, in case this info helps, if I download the file to the Ubuntu
machine, then I need to run the following command to convert it so that the
Japanese text is viewable on Ubuntu: (for example for windows text file
winText.txt):
iconv -f MS932 -t UTF-8 winText.txt -o linuxText_converted.txt
Please let me know if there is other info I can provide or other means to help
with this.
Thanks
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues