title: Broken UTF-8 Encoding in Jar Output
body: <p>I'm having problems with UTF-8 encoding when running jars from cmd. 
  When running the project from IntelliJIdea I don't have any problems, the characters are shown and are outputted correctly.</p>
  
  <p>To provide an example; I've used some of the suggested solutions from similar problems at here, stackoverflow, which I'll list.    </p>
  
  <pre><code>public static String convertToUTF8(String s) {
          String out = null;
          try {
              out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
          } catch (java.io.UnsupportedEncodingException e) {
              return null;
          }
          return out;
      }
  
      System.out.println(Charset.defaultCharset());
      String test = "written in utf-8İİiiŞŞŞĞĞÜĞĞğ";
      System.out.println(test);
      System.out.println(convertToUTF8(test));
      PrintWriter out = new PrintWriter(new File("hello.txt"), "UTF-8");
      out.print("written in utf-8İİiiŞŞŞĞĞÜĞĞğ");
      out.close();
  </code></pre>
  
  <p>The outputs are as follows;</p>
  
  <p><strong>Run from IntelliJIdea:</strong></p>
  
  <ul>
  <li><p>Console output:</p>
  
  <pre><code>UTF-8
  written in utf-8İİiiŞŞŞĞĞÜĞĞğ
  written in utf-8Ä°Ä°iiÅÅÅÄÄÃÄÄÄ
  </code></pre></li>
  <li><p>hello.txt: written in utf-8İİiiŞŞŞĞĞÜĞĞğ</p></li>
  </ul>
  
  <p><strong>Run from cmd, using jar</strong></p>
  
  <ul>
  <li><p>Console output:</p>
  
  <pre><code>windows-1252
  written in utf-8Ä°Ä°iiÅ?Å?Å?Ä?Ä???Ä?Ä?Ä?
  written in utf-8???°???°ii??Å???Å???Å???Å???Å???Å???Å???Å???Å?
  </code></pre></li>
  <li><p>hello.txt: written in utf-8Ä°Ä°iiÅžÅžÅžÄžÄžÃœÄžÄžÄŸ</p></li>
  </ul>
  
  <p>Other solutions that I've checked;</p>
  
  <ul>
  <li><p>Adding <code>-Dfile.encoding=utf-8</code> on cmd run, <code>java -Dfile.encoding=utf-8 -jar file.jar</code>: Changes nothing</p></li>
  <li><p>Using Ubuntu's terminal: the first line is UTF-8, but the rest is same as the cmd output.</p></li>
  <li><p>Running <code>chcp 65001</code> to change code page to UTF-8: while the visible output is fixed, hello.txt stays the same.</p></li>
  <li><p>Using powershell: Changes nothing.</p></li>
  </ul>
  
  <p>What I want to achieve is getting correct encoding handling while running jar files from cmd since I plan to use the jar as a background worker which will handle a lot of UTF-8 encoded characters.</p>
  
  <p><strong>Update:</strong>
  After replacing UTF-8 chars with unicode escape char equivalents; like ç to <code>\u011f</code>, the code runs as expected.
  The thing that bothers me is, while I can do the string replace function like replace("ç", '\u011f') and the jar runs smoothly, why doesn't the system handle it correctly when outputting? If the system understands the char ç at runtime, why do I get Ä characters in output?</p>