You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Robert Priest <Ro...@bentley.com> on 2003/09/03 23:33:10 UTC

[FileUpload] character encoding bug?

My Setup:

Windows 2000 Server,
jdk 1.4.1_01
Tomcat 4.1.7 (with a few upgrades. So I guess that would make it 4.1.7++)
file upload 1.0 (release)

I think there is an issue with UTF-8 encoding of filenames\files when going
through the fileupload package. I don't think it is handling special
characters right. I have been testing with a file named "ääää.txt"

Here is what I am seeing:

I attempt to upload this file using an <input type="file".../> field.

then when my jsp page takes over, I attempt to get the file name to print it
out

- calling: item.getName().

However item.getName() is returning a "C:\Documents and
Settings\Robert.Priest\Desktop\äää.txt" which is not the "given" name of
the file. 

When I usually write the file back out, I do a: 

String newFileName =
item.getName().substring(item.getName().lastIndexOf("\\")+1);

But with this behavior, this will not work with files containing these types
of characters in the name.



I think that somewhere in the code there is a conversion to "UTF-8", that is
causing this. But I don't know where.

This shouldn't be happening, right? 

Should I file a bug?

Where is that conversion taking place and should it be stopped or changed to
a different encoding?