1

I am able to see properly the file name in Chrome but not in IE getting the encoded format for filename

(e.g. =?UTF-8?B?5qWt55WM5pSv5Ye6UERGXzIwMTUwMjEwMTEwNjIy?=).

fileName = "=?UTF-8?B?" + new String(Base64.encodeBase64(fileName.getBytes("UTF-8")), "UTF-8") + "?=";

Please help me on this.

Adam
  • 35,919
  • 9
  • 100
  • 137
user3714194
  • 29
  • 1
  • 3
  • possible duplicate of [How to display a non-ascii filename in the file download box in browsers?](http://stackoverflow.com/questions/149058/how-to-display-a-non-ascii-filename-in-the-file-download-box-in-browsers) –  Feb 10 '15 at 06:51
  • Hi Adam, thanks for the inputs. we have tried your option but facing same issue. – user3714194 Feb 10 '15 at 06:58

1 Answers1

0

There is no nice cross browser solution for this. I found the nicely named article Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987 which summarises what different browsers support. Although I couldn't see anything on the base64 mechanism you're using.

There are many different variants, try using the URL encoding form, see http://greenbytes.de/tech/tc2231/#attwithfn2231utf8. Example

Content-Disposition: attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html

This claims better support, assuming you only want > IE8

FF22    pass
MSIE8   unsupported
MSIE9   pass
Opera   pass
Saf6    pass
Konq    pass
Chr25   pass

Depending on what version of IE you're hoping to support you may have to do some dirty USER_AGENT sniffing and send a header.

if (isUserAgentIe(requestHeaders)) {
   fileName = ...
} else {
   fileName = ...
}
Adam
  • 35,919
  • 9
  • 100
  • 137