commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14120] - [FileUpload] uploading files with non-ASCII filenames
Date Mon, 03 Mar 2003 11:38:21 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14120>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14120

[FileUpload] uploading files with non-ASCII filenames





------- Additional Comments From myohott@hotmail.com  2003-03-03 11:38 -------
Hi,Martin


I tried to upload a file which name is in japanese with the 
struts-upload.war(Jakarta Struts 1.1 RC1 distribution) as you said,in the 
display.jsp it still can not display the file's name correctly.




My test environment:


Windows2000 SP2 Japanese version


tomcat4.1.12


j2sdk1.4.1_01


struts1.1 rc1




I set the character encoding of the request to UTF8 by a filter,and write 


<%@ page language="java"  contentType="text/html;charset=utf-8" %>


<head>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


</head>


in the display.jsp,even with exchanging the fileName in the UploadAction by 
fileName = new String(fileName.getBytes(), "UTF-8") or not,but it failed in 
displaying the correct file name.




The problem maybe occurs when parsing the HTTP head from the request.


Here is the file name character encoding changing flow.


? The request character encoding has been set to UTF8 by the filter.


? Before the operation head = baos.toString(); in MultipartStream the head 
information is in a byte[] type.


? The toString() method translates bytes into characters according to the 
platform's default character encoding,in my case it's MS932 or you can say it 
Windos-31J.For some reason(MS932 character encoding can not map each UTF8 
charset bytes) a part of bytes can not be translated to MS932 correctly,so java 
use '?' to instead.It makes mistakes.


? When the sample UploadAction use String fileName= file.getFileName(); to get 
the file name,the result is a MS932 encoding String,when it is displayed by the 
UTF-8 display.jsp,no surprises it becomes a bogus file name.


? And if use fileName = new String(fileName.getBytes(), "UTF-8") to translate 
the file name back to UTF-8,since the untranslatable characters have already 
been changed to '?' for instead,in display.jsp there is a file name like this 
'*****??**'.(* as the correct japanese character)




So,i think you should test some two bytes character encoding sets one more 
time,and baos.toString(charset) (charset is the character encoding name of the 
request) is preferred.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message