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
  • 167,322
  • 27
  • 342
  • 338
kmb
  • 871
  • 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
  • 18,123
  • 6
  • 55
  • 121
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
  • 40,156
  • 8
  • 95
  • 98