0

Is it possible to export the name of the file with utf8 characters. we are using Servlet which is able to read the data and export it to the file but the name of the file is not with utf8 characters .

The file name should be exported as αβγδεζη.cft but it is exported as .cft. it replaces all Unicode characters with space.

Here is the screenshot :

enter image description here

I don't know from where to start with this problem. Any help is appreciated.

vermaraj
  • 634
  • 3
  • 10
  • 34
  • 1
    See http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http – GPI Jul 29 '14 at 12:48
  • @GPI i found something to work but still it doesn't work well on safari. – vermaraj Jul 31 '14 at 05:18

1 Answers1

0

@GPI Thanks for the help provided it was really helpful. Also want to share the below link from which i get started. Seems like, it has different functionality with different browser. See the scenario mentioned below :

I made some changes in java code to set the HTTP Content-Disposition header field.

String user_agent = request.getHeader("user-agent");
            boolean isInternetExplorer = (user_agent.indexOf("MSIE") > -1);
            if (isInternetExplorer) {
                response.setHeader("Content-disposition", "attachment; filename=\"" + URLEncoder.encode(templateName+".cft", "utf-8") + "\"");
            } else {                 
                response.addHeader("Content-Disposition", "attachment; " +"filename=\"" + MimeUtility.encodeWord(templateName+".cft", "utf-8", "Q") + "\"");
            }

But the above code is still not working for Safari 5.1.7 browser.

The above code works well on the following browsers :

  1. Firefox (Version 30.0)
  2. Chrome (Version 36.0.1985)
  3. IE (Version 8.0)

What if the user access the page on IE < 8 and same for other browsers.

vermaraj
  • 634
  • 3
  • 10
  • 34
  • can anybody answer why safari 5.1.7 is not supporting filename with utf8 characters. currently the filename shown on safari 5.1.7 **=-utf-8-Q-=CE=B1=CE=B2=CE=B3=CE=B4=CE=B5=2Ecft-=-1** – vermaraj Jul 31 '14 at 08:34