Although an old question, it is still relevant. I found a solution that works for all my browsers.
See my post in another topic:
Java servlet download special character file name
In short, browsers expect the value in the filename parameter to be encoded in the source encoding of the browsers (unless otherwise specified for the filename parameter). The native encoding of the browser is usually utf-8 (FF, Opera, Chrome), but for IE it is win-1250. Therefore, if we put the value in filename parametr, which is encoded by utf-8 / win-1250 according to the user's browser, it should work.
For example, if we have a file called omáčka.xml ,
for FireFox, Opera and Chrome I will answer this header (encoded in utf-8):
Content-Disposition: attachment; filename="omáčka.xml"
and for IE I answer this header (encoded in win-1250):
Content-Disposition: attachment; filename="omáèka.jpg"
Java example in my post mentioned above.
Note # 1 (@dkarp) :
Keep in mind the use of URLEncoder.encode (), as this method does not encode the input string into url encoding. This method encodes the input lines into an encoding form that is very similar, but different in some cases - for example, the space character '' is encoded as "+" instead of "% 20".
To perform the correct url encoding, you should use the URI class:
URI uri = new URI(null, null, "foo-ä-€.html", null); System.out.println(uri.toASCIIString());
sporak
source share