UTF-8 filename header

53 views
Skip to first unread message

Andrey Minogin

unread,
Mar 23, 2012, 5:36:28 AM3/23/12
to lib-gw...@googlegroups.com
Hello,

When I upload a file using ISO-8859-1 charset "filename" header also goes in ISO-8859-1. I use native UTF-8 filenames, so I need to convert filename header from ISO-8859-1 to UTF-8 on the server.

My questions are:
  1. Should I only use ISO-8859-1 when uploading a file? Cannot it be UTF-8?
  2. If I should, may I send content-body in ISO-8859-1, but the "filename" header in UTF-8?

Lukas Laag

unread,
Mar 25, 2012, 5:11:06 PM3/25/12
to lib-gw...@googlegroups.com, Andrey Minogin
On 03/23/2012 10:36 AM, Andrey Minogin wrote:
> Hello,
>
> When I upload a file using ISO-8859-1 charset "filename" header also
> goes in ISO-8859-1. I use native UTF-8 filenames, so I need to convert
> filename header from ISO-8859-1 to UTF-8 on the server.
>
> My questions are:
>
> 1. Should I only use ISO-8859-1 when uploading a file? Cannot it be UTF-8?
> 2. If I should, may I send content-body in ISO-8859-1, but the
> "filename" header in UTF-8?
>
Hi Andrey,

If you need to upload text files, the FileReader API provides a
http://www.vectomatic.org/mvn-sites/lib-gwt-file/apidocs/org/vectomatic/file/FileReader.html#readAsText%28org.vectomatic.file.Blob,%20java.lang.String%29
method. The spec says you ought to be able to specify an encoding in
which you want to obtain the data (I have not tried it with non-Unicode
encodings though).
As to the filename, it is available through the
http://www.vectomatic.org/mvn-sites/lib-gwt-file/apidocs/org/vectomatic/file/File.html#getName%28%29
method, so in this case it is a Unicode string.

So I think the question is more about the class you use to upload the
file, the encoding it supports, and how to find the best common
denominator between it and the File API. Can you tell us more about it
(XmlHttpRequest, FileUpload, other ?)

Regards

Lukas

Reply all
Reply to author
Forward
0 new messages