0

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?

tim_yates
  • 161,005
  • 26
  • 328
  • 327
kmb
  • 861
  • 5
  • 17
  • 34

2 Answers2

0

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?

Community
  • 1
  • 1
Michael-O
  • 17,715
  • 6
  • 54
  • 115
0

It's because Chrome and IE are buggy. "%" isn't special in Content-Disposition parameters, unless you use the encoding defined in RFC 5987.

Julian Reschke
  • 37,619
  • 8
  • 86
  • 92