I’d like to encode downloadable file name. I want to set file name with polish letters like ą ę ć ż ź. This is my code:
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("ŻżŹźĄą", 'UTF-8'))
It works on Chrome but MozillaFirefox shows it not correctly.
How to set encoding properly?
It won’t work. HTTP headers require implicitly either ASCII but upmost Latin 1 encoding. There is no standard to encode the name in UTF-8. Yolu will be better off if you decompose the letters. See this: How to encode the filename parameter of Content-Disposition header in HTTP?