title: Wrong encoding of file name with Spring MVC
body: <p>I have a Spring MVC handler method, that returns file <code>čšľ.csv</code>, but the file name comes wrongly encoded - I get <code>___.csv</code> in Chrome, or <code>???.csv</code> in Postman.</p>
  
  <p>The code can be seen here:</p>
  
  <pre><code>@SpringBootApplication
  @Controller
  public class EncodingsandboxApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(EncodingsandboxApplication.class, args);
      }
  
      @RequestMapping(value = "/",
              produces = {"text/csv"},
              method = RequestMethod.GET)
      public ResponseEntity&lt;Resource&gt; getExample() {
          return ResponseEntity.ok()
                  .contentType(new MediaType("text", "plain", StandardCharsets.UTF_8))
                  .header("Content-Disposition", "attachment; filename=čšľ.csv")
                  .build();
      }
  }
  </code></pre>
  
  <p>I'm expecting to get response with Content-Disposition header to be <code>attachment; filename=čšľ.csv</code>, but I've just got <code>attachment; filename=???.csv</code> (with Postman).</p>
  
  <p>Why is that and how can I get correctly encoded filename?</p>
  
  <p>I thought the "UTF_8" in <code>contentType(new MediaType("text", "plain", StandardCharsets.UTF_8))</code> will do the trick, but it won't. I've tried url encoded the filename (like this: <code>"attachment; filename=" + URLEncoder.encode("čšľ.csv", StandardCharsets.UTF_8)</code>), but I've just got literal url encoded filename.</p>
  
  <p>I also checked <code>spring.http.encoding.charset</code>, but UTF-8 is default here.</p>
  
  <p>My version of Spring boot is 2.2.0</p>